#33440: Cannot escape % character when using gettext
-----------------------------------------+------------------------
Reporter: Stian Jensen | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Reproduce:
Write something like `gettext('This item is 50% off!')`
run ./manage.py makemessages -a
find the string in the .po file and translate it like this:
#: templates/test.html:2
#, python-format
msgid "This item is 50% off!"
msgstr "Denne har 50% rabatt!"
run ./manage.py compilemessages
get this error message:
Execution of msgfmt failed: /Users/stiaje/Projects/django-
backend/app/hyre/locale/nb/LC_MESSAGES/django.po:601: format
specifications in 'msgid' and 'msgstr' for argument 1 are not the same
It works if the letter after the percentage is o in all languages, but
fails otherwise.
I tried escaping the percentage symbol as %%, but that resulted in %%
being outputted on runtime.
I tried using \u00e0 instead, but that gave:
Execution of msgfmt failed: /Users/stiaje/Projects/django-
backend/app/hyre/locale/nb/LC_MESSAGES/django.po:980:36: invalid control
sequence
I see that a very similar issue has been reported before, but it is
closed, with a comment saying to open a new issue for followups:
https://code.djangoproject.com/ticket/11240
I can make compilemessages work by manually removing python-format from
the strings with %, but makemessages will just add that back the next time
I run it.
--
Ticket URL: <https://code.djangoproject.com/ticket/33440>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.bc195587f37c9f37770659ed7d1906fb%40djangoproject.com.