Django missing translation of some strings. Any idea why?

我的梦境 提交于 2020-01-23 05:35:24

问题


I have a medium sized Django project, (running on AppEngine if it makes any difference), and have all the strings living in .po files like they should.

I'm seeing strange behavior where certain strings just don't translate. They show up in the .po file when I run make_messages, with the correct file locations marked where my {% trans %} tags are. The translations are in place and look correct compared to other strings on either side of them. But when I display the page in question, about 1/4 of the strings simply don't translate.

Digging into the relevant generated .mo file, I don't see either the msgid or the msgstr present.

Has anybody seen anything similar to this? Any idea what might be happening?

  • trans tags look correct
  • .po files look correct
  • no errors during compile_messages

回答1:


Ugh. Django, you're killing me.

Here's what was happening:

http://blog.e-shell.org/124

For some reason only Django knows, it decided to decorate some of my translations with the comment '# fuzzy'. It seems to have chosen which ones to mark randomly.

Anyway, #fuzzy means this: "don't translate this, even though here's the translation:"

I'll leave this here in case some other poor soul comes across it in the future.




回答2:


The fuzzy marker is added to the .po file by makemessages. When you have a new string (with no translations), it looks for similar strings, and includes them as the translation, with the fuzzy marker. This means, this is a crude match, so don't display it to the user, but it could be a good start for the human translator.

It isn't a Django behavior, it comes from the gettext facility.



来源:https://stackoverflow.com/questions/463714/django-missing-translation-of-some-strings-any-idea-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!