Yury Lifshits
Yury Lifshits

Reputation: 309

How do I change a language of a particular page in Django website

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.

Upvotes: 4

Views: 1498

Answers (1)

Yury Lifshits
Yury Lifshits

Reputation: 309

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’)

Upvotes: 5

Related Questions