Reputation: 6754
The problem is: if I set the English language as the primary language ( LANGUAGE_CODE = 'en' ) then all works fine. If we request the site from a browser with an English locale we see the English variant and analogically for a browser with a Russian locale.
But if I set LANGUAGE_CODE = 'ru' then we see the Russian variant in any case.
So why the English language is default and used by Django as msgid?
Please see the settings of my project below.
In my settings.py I try to set not English language as primary language:
LANGUAGE_CODE = 'ru'
LANGUAGES = ( ( 'en', "English", ), ( 'ru', "Russian", ), )
Then I have en/LC_MESSAGES/django.po:
msgid "SITE_MAIN_TITLE"
msgstr "D'argent: Cosmetics, Hair Care, Parfume"
And ru/LC_MESSAGES/django.po:
msgid "SITE_MAIN_TITLE"
msgstr "D'argent – косметика, средства по уходу за волосами, парфюмерия"
In template HTML:
...
<title>{% block title %}{% trans "SITE_MAIN_TITLE" %}{% endblock %}</title>
...
Upvotes: 2
Views: 2855
Reputation: 1138
IF you use this 'django.middleware.locale.LocaleMiddleware' middleware.
https://github.com/django/django/blob/master/django/utils/translation/trans_real.py#L366
see get_language_from_request function. Understand how to choose default language code. May be never used that settings.LANGUAGE_CODE ;).
Upvotes: 1