#27221: ugettext does not escape percent symbol
--------------------------------------+------------------------------
Reporter: pgcd | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.8
Severity: Normal | Keywords: ugettext percent
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------
While {% trans %} and {% blocktrans %} correctly escape '%' with '%%' in
templates, using ugettext or ugettext_lazy does not; this results in
errors with compilemessages.
Example:
{{{
price_adjust = models.DecimalField(max_digits=5, decimal_places=2,
default=1, choices=(('0.90', _('10% discount'), ))
}}}
will generate:
{{{
#, python-format
msgid "10% discount"
msgstr ""
}}}
When this is translated to German escaping the %, like:
{{{
#, python-format
msgid "10% discount"
msgstr "10%% Rabatt"
}}}
This results in an error message:
{{{
Execution of msgfmt failed:
/vagrant/src/locale_files/en/LC_MESSAGES/django.po:xxx: number of format
specifications in 'msgid' and 'msgstr' does not match
}}}
On the other hand, when it's not escaped, the error becomes:
{{{
Execution of msgfmt failed:
/vagrant/src/locale_files/en/LC_MESSAGES/django.po:xxx: 'msgstr' is not a
valid Python format string, unlike 'msgid'. Reason: In the directive
number 1, the character 'R' is not a valid conversion specifier.
}}}
Also, while trying to find a solution for this, I've found this
suggestion: https://code.djangoproject.com/ticket/24257#comment:2 - which
doesn't work for me at all. The only way I found is to use %(percent)s in
the string, which is awkward and difficult to read by the actual
translators.
--
Ticket URL: <https://code.djangoproject.com/ticket/27221>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.9454bd294c7718ec2bb0911483be687e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.