问题
In Django 1.6.5 the following worked: in settings.py
LANGUAGES = (
('sr_Latn', 'Srpski'),
('en', 'English'),
)
whereas the locale folder with translation was also called 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.
回答1:
It turns out Django devs did it right this time. The following setup worked like a charm:
Settings:
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
Everything finaly makes sense.
来源:https://stackoverflow.com/questions/35760101/django-1-9-sr-latn-locale-doesnt-work