8

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?

1 Answers1

5

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

  • 1
    I made all the suggestions you show but nothing that works the translations of my site... – Cristian Flórez Aug 03 '20 at 22:11
  • I changed the case in the locale folder and the LANGUAGE_CODE to my "second" language and it worked. It always falls back to English or uses my second language, in the example should be ru_RU – Joel Carneiro May 24 '21 at 14:41