Django 1.9 sr_Latn语言环境不起作用 [英] Django 1.9 sr_Latn locale doesn't work
问题描述
在Django 1.6.5中,以下工作有效:在settings.py
In Django 1.6.5 the following worked: in settings.py
LANGUAGES = (
('sr_Latn', 'Srpski'),
('en', 'English'),
)
带有翻译的语言环境文件夹也称为 sr_Latn .
whereas the locale folder with translation was also called sr_Latn.
使用Django 1.9.2.sr_Latn不再被识别为语言代码,因此我必须输入sr-latn,但是找不到locale文件夹-无论它是sr-latn,sr-Latn,sr_latn还是sr_Latn.
With Django 1.9.2. sr_Latn is not recognized as a language code any more so I have to enter sr-latn, but then the locale folder is not found - regardless if it is called sr-latn, sr-Latn, sr_latn or sr_Latn.
LANGUAGES = (
('sr-latn', 'Srpski'),
('en', 'English'),
)
此问题仅针对塞尔维亚拉丁语,因为这是唯一具有这种有趣格式的语言环境.
This problem is specific to Serbian-Latin only because that is the only locale to have such a funny format.
推荐答案
事实证明Django开发人员这次做对了.以下设置非常有效:
It turns out Django devs did it right this time. The following setup worked like a charm:
设置:
LANGUAGES = (
('sr-latn', 'Srpski'),
('en-gb', 'English'),
)
LOCALE_PATHS = (
# translation files on the server must be in the same folder as this
# settings file and this path must point to the translations.
# Dev server works anyway with this path.
os.path.join(os.path.dirname(__file__), "locale"),
)
我在项目"文件夹中有语言环境文件夹:
I have locale folder in the Project folder:
./project-folder/
locale/
sr_Latn/
LC_MESSAGES/
django.mo
django.po
en_GB/
LC_MESSAGES/
django.mo
django.po
一切皆有道理.
这篇关于Django 1.9 sr_Latn语言环境不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!