Opened 15 years ago

Closed 13 years ago

Last modified 13 years ago

#11966 closed (fixed)

Error: errors happened while running xgettext over template file with a literal that contains '%'

Reported by: Adrian Ribao Owned by: nobody
Component: Internationalization Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I find an error when running

manage.py makemessages -a

The problem comes when it reads a .html file with this content:

{% blocktrans %}This is some text ... 75% ... more text ... 75% of ...{% endblocktrans %}

The error is:

Error: errors happened while running xgettext on info-tripartita.html
./templates/myfile.html.py:98: atención: 'msgid' format string with unnamed arguments cannot be properly localized:
                                                                 The translator cannot reorder the arguments.
                                                                 Please consider using a format string with named arguments,
                                                                 and a mapping instead of a tuple for the arguments.

It's ok if there is only one % symbol in the string and even if the string has no characters after the second %:

{% blocktrans %}This is some text ... 75% ... more text ... 75%{% endblocktrans %}

I can't find a way to solve this problem.

Attachments (1)

11966.patch (2.3 KB ) - added by Claude Paroz 14 years ago.
Fix + tests

Download all attachments as: .zip

Change History (6)

comment:1 by Ramiro Morales, 14 years ago

Summary: Error: errors happened while running xgettextError: errors happened while running xgettext over template file with a literal that contains '%'

comment:2 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

by Claude Paroz, 14 years ago

Attachment: 11966.patch added

Fix + tests

comment:3 by Claude Paroz, 14 years ago

Has patch: set

Attached patch (download it if Trac doesn't show it) tries a simple fix in doubling all '%' signs found inside a translatable strings. I'm not completely convinces it's safe to do so, but I think we miss some extensive tests regarding templatize results. A more clever solution would test if there is another "%(var)s" in the string, and if not, simply output a # no-python-format comment so as xgettext uses it.

comment:4 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

(In [14459]) Fixed #11966 -- Made it possible to use a percent sign in a translation message id. Thanks for the patch, Claude Paroz.

comment:5 by Jannis Leidel, 13 years ago

(In [14460]) [1.2.X] Fixed #11966 -- Made it possible to use a percent sign in a translation message id. Thanks for the patch, Claude Paroz.

Backport from trunk (r14459).

Note: See TracTickets for help on using tickets.
Back to Top