0
我一直在开发一个应用程序在英文或法文(加拿大)工作。 Django的设置是;Django翻译没有显示从应用程序的口
LANGUAGE_CODE = 'en'
LANGUAGES = [
('en', gettext('English')),
('fr-ca', gettext('Canadian French')),
]
LOCALE_PATHS = (
...
os.path.join(PROJECT_ROOT, 'console', 'locale'),
...
)
应用程序的语言环境路径是console/locale/fr-CA/LC_MESSAGES/
的应用然而最近停止渲染绝大多数翻译,而Django的调试工具栏,和其他应用程序都没有问题显示法语。
例如,我有一个'名字','姓','电子邮件'的表格。昨天这是正确使用po文件;
#: console/forms/participants.py:631
msgid "First Name"
msgstr "Prénom"
#: console/forms/participants.py:635
msgid "Last Name"
msgstr "Nom"
#: console/forms/participants.py:140 console/forms/participants.py:469
#: console/forms/participants.py:639 console/models/mixins.py:70
msgid "Email"
msgstr "Courriel"
但今天,只有Email
字符串出现在法国。我假设ugettext
正从另一个应用程序中获取,因为我已经在shell中测试过它;
>>> from django.utils.translation import ugettext, activate
>>> activate('fr-ca')
>>> ugettext('Sunday')
u'dimanche'
>>> ugettext('Event')
u'Event'
>>> ugettext('Yes')
u'Oui'
>>> ugettext('Gender')
u'Gender'
>>> ugettext('enquiry')
u'enquiry'
>>> ugettext('Enquiry')
u'Enquiry'
>>> ugettext('Receive notifications about other events.')
u'Receive notifications about other events.'
这些都是取自应用程序的po文件;
#: console/models/events.py:35 console/models/events.py:206
#: console/models/participants.py:81 console/models/vouchers.py:14
msgid "Event"
msgstr "Événement"
#: console/models/participants.py:113
msgid "Gender"
msgstr "Sexe"
#: console/models/participants.py:160
msgid "Receive notifications about other events."
msgstr "Recevez des notifications pour un événement."
不用说我已经跑了翻译管理命令(和可以看到的区域设置路径是输出);
manage.py makemessages -l fr-CA
manage.py compilemessages -l fr-CA
大部分的东西都存在着使用ugettext_lazy与型板T沿着模型和形式ranslations。了解一个字符串来自哪个翻译文件会很棒。将有助于看到被翻译的东西来自哪里。 –