Reputation: 5428
I have the very first experience of using django i18n. I've done the following steps:
Added to settings.py:
USE_TZ = True
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'en'
LANGUAGES = (
('ru', _('Russian')),
('en', _('English')),
)
ugettext = lambda s: s
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
template:
{% blocktrans %}WTS{% endblocktrans %}
console:
./env/bin/django-admin.py makemessages -l ru
./env/bin/django-admin.py makemessages -l ru
.po file:
msgid "WTS"
msgstr "ВИС"
console:
./env/bin/django-admin.py compilemessages
Now I want to check translation. I'm using firefox browser that sends request.META['LANG'] as 'en_US.utf8' and I get only original content of blocktrans. How to check translations and what I forgout to implement before testing?
Upvotes: 0
Views: 192
Reputation: 442
A very rough workaround: add translation.activate(user_language)
code to your view, where user_language - required locale (e.g.: user_language = 'ru'
).
For a solid solution - implement code for switching languages or play with browser's locale settings.
See more details here: https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference
Upvotes: 1