How do I change a language of a particular page in Django website
-
20-09-2019 - |
Question
Django internationalization allows me to set a language code either in settings file (site-wide) or on per-user / per-session basis.
How can I change language for a particular page?
I wrote a middleware that sets request.LANGUAGE_CODE the way I want it to be translated, but nothing seems to use this attribute to do the selected translation.
Solution
Great, I have found an answer here: http://fseoane.net/blog/2009/django-change-language-settings-dynamically
Here is how can change the Django language dynamically
from django.utils.translation import activate
activate(‘es-ES’)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow