Processing percent sign (%) in blocktrans tags in Django

I am currently localizing my Django application. All other translations work just fine, with the exception of the percent sign inside blocktrans tags.

There is one in my template {% blocktrans %}Original % blocktrans{endblocktrans %}.

django-admin makemessages produces this in django.po:

#: templates/index.html:78
#, python-format
msgid "Original %% blocktrans"
msgstr ""

I update this to msgstr "Translated %% blocktrans", start django-admin compilemessages, restart the dev server and refresh the page, but I still see Original % blocktransthe output. Other translations are displayed correctly.

For reference, {% trans "Original % trans" %}also works fine. After makemessages and translation, I have:

#: templates/index.html:72
msgid "Original % trans"
msgstr "Translated % trans"

This works as expected - the translated version is displayed.

I have to use blocktrans because I also need to insert variables into strings. I am using Django 1.2.5.

How to make blocktrans work with percentage signs?

+5
3

, : PERCENT_SIGN = u '%' {{PERCENT_SIGN}} blocktrans-.

+2

- , ,

+3

For this particular problem, another ticket was opened with a fix correcting it. Hope it will be fixed for Django 1.4.

https://code.djangoproject.com/ticket/16721

+2
source

All Articles