When I try to translates empty strings in a django template I end up with the po header showing up instead an empty string http://codex.wordpress.org/Translating_WordPress#The_PO_File_Header . I have to translate empty strings because they are in db an I can't fill all models and translate them as they are dynamic. Now I use something like

{% if data %}
    {% trans data %}
{% endif %}

I tried to mark the header as fuzzy but it didn't work.

Is there any way to avoid to check each translatable string and avoid the po header showing up ? I am using django 1.5.

有帮助吗?

解决方案

Ok, found out what was going on, according to Why does gettext translate an empty string to the .po header text? and http://www.gnu.org/software/gettext/manual/gettext.html#MO-Files

Having the original strings sorted enables the use of simple binary search, for when the MO file does not contain an hashing table, or for when it is not practical to use the hashing table provided in the MO file. This also has another advantage, as the empty string in a PO file GNU gettext is usually translated into some system information attached to that particular MO file, and the empty string necessarily becomes the first in both the original and translated tables, making the system information very easy to find.

So I can't avoid checking the string.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top