我为language de和en。
创建了.po和.mo文件的翻译当我用德语设置午餐时,用
print(translation.get_language())
>> de
它打印正确的语言,但翻译不起作用(我得到英文翻译)
我有:
# Translations
# Provide a lists of languages which your site supports.
LANGUAGES = (
('en', _('English')),
('de', _('German')),
)
# Set the default language for your site.
LANGUAGE_CODE = 'de'
# Tell Django where the project's translation files should be.
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
在HTML中
{% load i18n %}
<label class="bmd-label-static" for="date">{% trans 'Date' %}</label>
在django.po
msgid "Date"
msgstr "Datum"
我的文件排列如下:
locale
|
-> de
|
-> LC_MESSAGES
|
-> django.mo
-> django.po
-> en
|
-> LC_MESSAGES
|
-> django.mo
-> django.po