I'm currently localizing my Django app. All other translations work fine except percent-sign inside blocktrans tags.
In my template I have {% blocktrans %}Original % blocktrans{endblocktrans %}
.
django-admin makemessages
produces this in django.po:
#: templates/index.html:78
#, python-format
msgid "Original %% blocktrans"
msgstr ""
I update that to msgstr "Translated %% blocktrans"
, run django-admin compilemessages
, restart dev server and refresh the page, but I still see Original % blocktrans
in the output. Other translations are shown properly.
For reference, {% trans "Original % trans" %}
also works ok. After makemessages and translation I have:
#: templates/index.html:72
msgid "Original % trans"
msgstr "Translated % trans"
This works as expected - translated version is shown.
I must use blocktrans because I also need to embed variables to the strings. I'm using Django 1.2.5.
How can I make blocktrans work with percent-signs?
Check out this ticket - it's not a solution, but it sheds light on what's going on
Couldn't find a real solution to the problem, so I used a workaround: create a constant PERCENT_SIGN = u'%' and use that as {{ PERCENT_SIGN }} inside blocktrans-blocks.
Another ticket has been opened for this particular issue, with a patch that fixes it. Hopefully it will be fixed for Django 1.4.
https://code.djangoproject.com/ticket/16721
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With