I've made translation of the site for different cities and it works fine on dev machine. But when published on production server it didn't show any translation.
But it shows available languages and current language correctly.
Here's my settings.py:
USE_I18N = True
USE_L10N = True
LANGUAGES = [
('ru-spb', _('SaintP')),
('ru-msk', _('Moscow')),
]
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'nordicsite/locale'),
)
Here's template for language check:
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{{server}}<br/>
{% trans 'Test 2' %}<br/>
{{LANGUAGE_CODE}}<br/>
{% for language in languages %}
{{ language.name_local }} ({{ language.code }})<br/>
{% endfor %}
<br/>
{% for path in paths %}
{{path}}<br/>
{% endfor %}
Output for dev:
Тест 1 Питер
Тест 2 Питер
ru-spb
Русский (ru)
Русский (ru)
/*****/nordicsite/locale
Output for production:
Test 1
Test 2
ru-spb
Русский (ru)
Русский (ru)
/*****/nordicsite/locale
What can be wrong?
Finally i figured out what was wrong. My dev machine - Mac and production - Ubuntu. And it didn't work width fake language codes like ru-spb and ru-msk. I changed it to ru-ru and ru-ua and started working correctly.
One more thing. Ubuntu needs locale folder to be ru_RU (not ru_ru).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With