为什么 Django 只显示我的一些翻译

发布于 2024-10-02 16:04:25 字数 507 浏览 7 评论 0原文

我有一个网站,其 HTML 模板以及 views.pyforms.pymodels.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反话 2024-10-09 16:04:25

1.确保在模型和表单定义中始终使用 ugettext_lazy (而不是 ugettext

2.删除可能的 .mo 文件中的模糊 标记

1.Make sure you are always using ugettext_lazy (not ugettext) in model and form definitions

2.Remove possible fuzzy tags in the .mo files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文