django 模糊字符串翻译未显示
为什么有时我会在
<前><代码>#: .\users\views.py:81 .\users\views.py:101 #、模糊 msgstr "用户名或电子邮件" 消息字符串“9988”django.po
语言文件中得到一个模糊
项。实际上,我已经在我的项目中检查了fuzzy
字符串项是完全唯一的。模糊是可以的,但是我对模糊项目的翻译没有显示在页面上,只显示英文版本。这完全是奇怪的。
Why sometimes I get a
fuzzy
item indjango.po
language file. Actually, I have checked in my project thefuzzy
string item is totally unique.#: .\users\views.py:81 .\users\views.py:101 #, fuzzy msgid "username or email" msgstr "9988"
It is ok to be fuzzy but my translation of fuzzy item not showing up on the page, only English version shows up. It is totally odd.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
msgid
的字符串进行了翻译,msgmerge
将字符串标记为模糊
。它还将标记为模糊的字符串从旧目录转移到新目录。msgfmt
从编译的目录中排除模糊消息,因为翻译可能不正确。译者应该检查翻译的正确性(在您发布的情况下,空字符串显然是错误的翻译),并在翻译验证后删除模糊
标记。如果您绝对想使用模糊翻译,请将--use-fuzzy
传递给msgfmt
:msgmerge
marks strings asfuzzy
if the old catalog had a translation for a strings with a similar-lookingmsgid
. It also carries over strings marked as fuzzy from an old catalog to a new one.msgfmt
excludes fuzzy messages from the compiled catalog, as the translations are likely incorrect. The translator should check correctness of the translation (in the case you posted, an empty string is clearly an incorrect translation), and remove thefuzzy
mark when the translation is is verified. If you absolutely want to use fuzzy translations, pass--use-fuzzy
tomsgfmt
:我也遇到了这些问题,我通过使用突出显示模糊的“po 编辑器”(如 poedit)解决了所有这些问题和未翻译的条目,使翻译过程更快。
您还可以使用 Django Rosetta 将翻译过程集成到您的 Django 环境中。
I also had these problems and I solved them all by using a 'po editor' (like poedit) which highlights fuzzy and untranslated entries and makes the translation process much faster.
You can also use Django Rosetta to have the translating process integrated in your Django environment.
非常感谢 @Martin v. Löwis 的第一个回答。
是的,效果很好。就我而言,使用
--use-fuzzy
开关非常有用。就我而言,
.po
文件行的内容(不起作用)如下所示。除了这一行之外,所有翻译的行都有效。这是执行 django-admincompilemessages --use-fuzzy 后我的终端的输出。
最后,运行命令后,只需重新启动服务器即可,即
python manage.py runserver
。Very thanks to the 1st answer by @Martin v. Löwis.
Yes, that worked great. In my case, using
--use-fuzzy
switch was very useful.In my case, the content of
.po
file lines (not working) was something like below. All translated lines were working except this.Here is output of my terminal after executing
django-admin compilemessages --use-fuzzy
.Finally, after running the command, just restart the server i.e.
python manage.py runserver
.