Using blocktrans for translation
I am using the following blocktrans:
{% blocktrans with item|gender_text as gendertext %}
This is {{gendertext}} item
{% endblocktrans %}
In my .po file I have
msgid "This is %(gendertext)s item"
msgstr "Some translation ... %(gendertext)s"
For any language other than english, I would not like to use the gendertext
variable. So I would want to have
msgstr "Some translation ..."
However, when I tak开发者_如何学Ce off the %(gendertext)s
from from msgstr
, django_admin shouts (when compiling the messages):
'msgstr' is not a valid Python format string, unlike 'msgid'. Reason: The string ends in the middle of a directive.
msgfmt: found 1 fatal error
Any workarounds for this case?
Meir
If I understand your question well, Django is right to give that error beacsue, your key should be there for all languages.For example, there is no such case : in English I have a key gendertext
but in Turkish I don't need that key.
One easy solution is keep that key in both languages but keep it empty if you don't want to render.
Other than your question, I strongly recommend you to use rosetta
application, http://code.google.com/p/django-rosetta/ for translation processes.
精彩评论