django 模糊字符串翻译未显示

发布于 2024-08-04 00:45:49 字数 293 浏览 7 评论 0原文

  1. 为什么有时我会在 django.po 语言文件中得到一个模糊项。实际上,我已经在我的项目中检查了 fuzzy 字符串项是完全唯一的。

    <前><代码>#: .\users\views.py:81 .\users\views.py:101 #、模糊 msgstr "用户名或电子邮件" 消息字符串“9988”
  2. 模糊是可以的,但是我对模糊项目的翻译没有显示在页面上,只显示英文版本。这完全是奇怪的。

  1. Why sometimes I get a fuzzy item in django.po language file. Actually, I have checked in my project the fuzzy string item is totally unique.

    #: .\users\views.py:81 .\users\views.py:101
    #, fuzzy
    msgid "username or email"
    msgstr "9988"
    
  2. 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 技术交流群。

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

发布评论

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

评论(3

腻橙味 2024-08-11 00:45:49

  1. 如果旧目录对具有类似 msgid 的字符串进行了翻译,

    msgmerge 将字符串标记为模糊。它还将标记为模糊的字符串从旧目录转移到新目录。

  2. msgfmt 从编译的目录中排除模糊消息,因为翻译可能不正确。译者应该检查翻译的正确性(在您发布的情况下,空字符串显然是错误的翻译),并在翻译验证后删除模糊标记。如果您绝对想使用模糊翻译,请将 --use-fuzzy 传递给 msgfmt

python manage.py compilemessages --use-fuzzy

  1. msgmerge marks strings as fuzzy if the old catalog had a translation for a strings with a similar-looking msgid. It also carries over strings marked as fuzzy from an old catalog to a new one.

  2. 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 the fuzzy mark when the translation is is verified. If you absolutely want to use fuzzy translations, pass --use-fuzzy to msgfmt:

python manage.py compilemessages --use-fuzzy
伴我老 2024-08-11 00:45:49

我也遇到了这些问题,我通过使用突出显示模糊的“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.

青巷忧颜 2024-08-11 00:45:49

非常感谢 @Martin v. Löwis 的第一个回答。

是的,效果很好。就我而言,使用 --use-fuzzy 开关非常有用。

就我而言,.po 文件行的内容(不起作用)如下所示。除了这一行之外,所有翻译的行都有效。

#: ui/templates/theme/html/ltr/vertical-menu-template-nav-dark/login.html:58
#, fuzzy
#| msgid "Already a registered user (Login)"
msgid "Not a registered user (Create account)"
msgstr "Уже зарегистрированный пользователь (логин)"

这是执行 django-admincompilemessages --use-fuzzy 后我的终端的输出。

(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ django-admin compilemessages --use-fuzzy
processing file django.po in /Users/hygull/Projects/Python36/Django/Others/AMCProj/amc/src/locale/hi/LC_MESSAGES
processing file django.po in /Users/hygull/Projects/Python36/Django/Others/AMCProj/amc/src/locale/ru/LC_MESSAGES
processing file django.po in /Users/hygull/Projects/Python36/Django/Others/AMCProj/amc/src/locale/en/LC_MESSAGES

最后,运行命令后,只需重新启动服务器即可,即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.

#: ui/templates/theme/html/ltr/vertical-menu-template-nav-dark/login.html:58
#, fuzzy
#| msgid "Already a registered user (Login)"
msgid "Not a registered user (Create account)"
msgstr "Уже зарегистрированный пользователь (логин)"

Here is output of my terminal after executing django-admin compilemessages --use-fuzzy.

(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ django-admin compilemessages --use-fuzzy
processing file django.po in /Users/hygull/Projects/Python36/Django/Others/AMCProj/amc/src/locale/hi/LC_MESSAGES
processing file django.po in /Users/hygull/Projects/Python36/Django/Others/AMCProj/amc/src/locale/ru/LC_MESSAGES
processing file django.po in /Users/hygull/Projects/Python36/Django/Others/AMCProj/amc/src/locale/en/LC_MESSAGES

Finally, after running the command, just restart the server i.e. python manage.py runserver.

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