[Answered ]-Django custom locale directory

2👍

AFAIK, python-gettext can’t use different folder, so… Use Symlinks, Luke!

0👍

Make sure your directory structure for localization files look like that:

locale/en/LC_MESSAGES/django.mo 
locale/ru/LC_MESSAGES/django.mo

If you name them something else, or put them elsewhere, it probably won’t work.

You also need to pust aproperiate l18n information in your settings file. LANGUAGE_CODE = 'en' in one, and LANGUAGE_CODE = 'ru' in the other.

Edit: Have you created two separate apps or two separate project? Apps usually don’t have their own settings.py and manage.py…

You can have one project that have multiple settings files and runs multiple websites. It would be much more django-ish (and much easier to deal with) for your directory structure to look like this:

/settings_ru.py # SITE_ID = 1 
/settings_en.py # SITE_ID = 2 
/manage.py # use --settings option to distinguish between settings files.
/urls.py 
/templates/ # templates with {% trans %} 
/locale/ # locale/en/LC_MESSAGES/django.mo and locale/ru/LC_MESSAGES/django.mo 
(+ other common code, inside their respective apps)

Leave a comment