views:

169

answers:

2

I'm developing a project with two different sites, divided by language. Maybe I was terribly wrong, but now my directory structure looks like:

/ruapp/settings.py # SITE_ID = 1 
/ruapp/manage.py 
/enapp/settings.py # SITE_ID = 2 
/enapp/manage.py 
/common/urls.py 
/common/ # almost every other file 
/common/templates/ # templates with {% trans %} 
/locale/ # with locales ru-ru and en-us, generated by calling 
makemessages from the root of all this structure

How to tell django about the locale? It does not seem like it will find the /locale/ folder by itself

A: 

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)
Ludwik Trammer
A: 

AFAIK, python-gettext can't use different folder, so... Use Symlinks, Luke!

myfreeweb