How to change the language of a specific page on a Django website

Internationalization of Django allows me to set the language code either in the settings file (throughout the site), or for each user / per session.

How can I change the language for a specific page?

I wrote a middleware that sets request.LANGUAGE_CODE the way I want it to be translated, but uses nothing of this attribute to execute the selected translation.

+3
source share
1 answer

Great, I found the answer here: http://fseoane.net/blog/2009/django-change-language-settings-dynamically

Django

from django.utils.translation import activate

activate(‘es-ES’)
+4

Source: https://habr.com/ru/post/1732969/


All Articles