为什么 Django 只显示我的一些翻译
我有一个网站,其 HTML 模板以及 views.py
、forms.py
和 models.py
文件中都包含翻译字符串。 Django 为我的第二语言创建了 django.po 文件,并且我已经输入了大部分翻译。但是,网站上仅显示我的 .html 和 view.py 文件中的翻译。其他的似乎被忽略了(models.py、forms.py - 都默认为英语)
发生了什么事?
显然我已经编译了我的 django.mo
文件并且它正在工作 - 否则很多模板字符串不会被翻译 - 那么为什么它忽略我的 models.py
翻译。在管理站点和前端。
一种想法是 django.mo 文件中可能存在错误导致其损坏。有没有办法测试 django.mo 文件是否有错误?如果出现错误,它还能工作吗?
我的项目还安装了 Django-cms,这可能会导致一些冲突?
感谢任何光棚。
盖伊
I've got a site with translation strings in both the HTML templates and the views.py
, forms.py
and models.py
files. Django has created the django.po
file for my second language, and I have entered most of the translations. However, only translations in my .html and view.py files are showing up on the site. the others are being ignored it seems (models.py, forms.py - both defaulting to English)
What's going on?
I've obviously compiled my django.mo
file and that's working - otherwise a lot of template strings wouldn't be translated - so why is it ignoring my models.py
translations. Both in the admin site and the front end.
One thought is that there may be an error in the django.mo
file that causes it to break. Is there any way to test a django.mo
file for errors? Would it work at all if there was an error?
My project also has Django-cms installed, which could be causing some conflict?
Thanks for any light shed.
Guy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1.确保在模型和表单定义中始终使用
ugettext_lazy
(而不是ugettext
)2.删除可能的 .mo 文件中的
模糊
标记。1.Make sure you are always using
ugettext_lazy
(notugettext
) in model and form definitions2.Remove possible
fuzzy
tags in the .mo files.