Translation problem with percent sign

370 views
Skip to first unread message

Martin Tiršel

unread,
Nov 4, 2011, 10:01:13 AM11/4/11
to Django users
Hello,

I am using Django 1.2.5.


* template:

{% trans 'If you cancel queued construction, you will get 75% of resources
back' %}


* django-admin.py makemessages -l sk produces:

#: templates/core/buildings/construction.html:65
#, python-format
msgid "If you cancel queued construction, you will get 75% of resources
back"
msgstr ""

I open the .po file in poedit program and add translation "Zrušením budovy
v stavebnom rade sa ti vráti 75% surovín" what produces:

1375 #: templates/core/buildings/construction.html:65
1376 #, python-format
1377 msgid "If you cancel queued construction, you will get 75% of
resources back"
1378 msgstr "Zrušením budovy v stavebnom rade sa ti vráti 75% surovín"

And poedit (or django compilemessages) shows me an error
"...po:1378:format specification in 'msgid' nad 'msgstr' for argument a
are not the same". When I add 75%% in my translated string doesn't work
either, I need to manually edit the msgid string and change % for %%, so
it looks so:

1375 #: templates/core/buildings/construction.html:65
1376 #, python-format
1377 msgid "If you cancel queued construction, you will get 75%% of
resources back"
1378 msgstr "Zrušením budovy v stavebnom rade sa ti vráti 75%% surovín"

This will compile. But no translation occurs because it seems that {%
trans %} can not handle percent sign. Is it so or I am doing something
wrong?


I could split the string into two translation string like this:

{% trans 'If you cancel queued construction, you will get' %} 75% {% trans
'of resources back' %}

but this seems a little bit ugly. Or I could use HTML entity % or
perhaps use {% blocktrans %} and instead of % use some variable like {{
PERCENT_SIGN }}. But all of this is a little bit complicated so I first
need to know if I am not doing something bad or perhaps there is a bug in
Django.

Thanks,
Martin

Martin J. Laubach

unread,
Nov 4, 2011, 10:54:04 AM11/4/11
to django...@googlegroups.com
  Just remove the line with "python-format" from your translation since it isn't a format string after all.

        mjl

Martin Tiršel

unread,
Nov 5, 2011, 9:55:37 PM11/5/11
to django...@googlegroups.com

Thanks, this is working. But after makemessages It comes again so I have
to fix this line every time.

Martin

Reply all
Reply to author
Forward
0 new messages