2010-03-29 79 views
1

我正在開發一個項目,其中包含兩個不同的站點,除以 語言。也許我是可怕的錯誤,但現在我的目錄結構 樣子:Django自定義區域設置目錄

/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 

如何告訴Django有關的語言環境?它看起來像它本身不將 找到/區域/文件夾

+0

關於本地文件夾? – myfreeweb 2010-03-29 19:12:22

+0

是的,關於locale文件夾。 – 2010-03-29 19:16:46

回答

2

據我所知,蟒蛇,gettext的不能用不同的文件夾,所以...使用符號鏈接,盧克!

0

確保您的目錄結構的本地化文件看起來像:

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

如果您還有他們的名字的東西,或者把它們放在別處,它可能不會工作。

您還需要在設置文件中添加aproperiate l18n信息。其中一個爲LANGUAGE_CODE = 'en',另一個爲LANGUAGE_CODE = 'ru'

編輯:有您創建了兩個獨立的應用或兩個獨立項目?應用程序通常沒有自己的settings.py和manage.py ...

您可以讓一個項目具有多個設置文件並運行多個網站。這將是更Django的ISH(和更容易處理)爲您的目錄結構,看起來像這樣:

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