Search code examples
djangotemplatestranslationpercentagedjango-i18n

Django translations block not translated


I have a Django 1.6 template with the following content (base language is german, the translation is in english):

{% trans "My App" as appname %}
{% blocktrans with appname=appname %}Garantie: '{{ appname }}' ist 100%% gratis!{% endblocktrans %}
{% trans "Hallo {firstWordInName}," %}

When generating the .po files it looks like that:

msgid "Garantie: '%(appname)s' ist 100%% gratis!"
msgstr "We assure you: '%(appname)s' is 100%% free of charge!"

msgid "Hallo {firstWordInName},"
msgstr "Hello {firstWordInName},"

But when rendering the django template only the string "Hallo {firstWordInName}," is translated. The other one keeps being german. What is the reason for that? I think django translations for strings with percentage signs are really broken....

Thanks in advance! Any help is appreciated!


Solution

  • I found a simple solution, maybe even better than the one suggested in Handling percent-sign (%) in Django blocktrans tags

    {% blocktrans with percent="%" %} This is 100{{ percent }} working! {% endblocktrans %}