Reputation: 11
In a template in DJango I need to keep %s as a result of a translation.
Example:
{% trans '%s record' %}
Needs to translate to:
English:
%s record
Dutch:
%s opname
Problem is that in de django.po file, ik heeps adding:
#, fuzzy, python-format
msgid "%%s record"
msgstr "%s opname"
Correct function code:
msgid "%s record"
msgstr "%s opname"
But every run on ./manage.py compilemessages
creates the wrong code.
Upvotes: 1
Views: 621
Reputation: 5666
If you need variable translation - use {% blocktrans %}{% endblocktrans %}
instead.
Like this:
<p>
{% blocktrans %}
{{ variable }} record
{% endblocktrans %}
</p>
Django picks it up and creates correct translation string from it.
Upvotes: 1