Opened 18 years ago

Closed 18 years ago

#3410 closed (fixed)

make-messages has warnings while running xgettext on validators.py, /contrib/admin/views/doc.py, and /utils/html.py

Reported by: mirrorballu2@… Owned by: hugo
Component: Internationalization Version: dev
Severity: Keywords: gettext
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm getting these errors when I run

./bin/make-messages.py -l pt_BR

from the root django directory:

errors happened while running xgettext on validators.py
./core/validators.py:364: warning: '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.

Attachments (3)

ticket-3410.diff (1.1 KB ) - added by Michael Radziej <mir@…> 18 years ago.
changes format to dict style
ticket-3410.2.diff (1.1 KB ) - added by Michael Radziej <mir@…> 18 years ago.
revised patch
docpatch.diff (1.5 KB ) - added by mirrorballu2@… 18 years ago.
A patch for doc.py

Download all attachments as: .zip

Change History (16)

comment:1 by Michael Radziej <mir@…>, 18 years ago

Summary: errors while running xgettext on validators.pymake-messages cannot deal with non-ASCII message ids
Triage Stage: UnreviewedDesign decision needed

Yeah, make-messages is unable to deal with message-ids that contain non-ASCII characters. It's because the way make-messages assembles the translation files doesn't allow to specify an encoding, and it's not easily fixed. I'd personally be very thankful for a patch, as I tried and was unable to fix it.

I'm dealing with this by myself with a German-German translation, i.e. in the code I use

_("Mueller")

and then I have a translation entry that translates "Mueller" to "Müller".

This is *really* nasty. I leave it to the core to decide whether this is a bug. Please take my word, this is not just a minor inconvenience.

comment:2 by anonymous, 18 years ago

But why are there non-ASCII characters in a core module?

comment:3 by anonymous, 18 years ago

The offending string appears to be "This value must be between %s and %s." and it doesn't contain any non-ASCII characters.

comment:4 by mirrorballu2@…, 18 years ago

Now I'm getting a different error:

./core/validators.py:364: warning: '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.

comment:5 by Michael Radziej <mir@…>, 18 years ago

Has patch: set
Summary: make-messages cannot deal with non-ASCII message idsmake-messages has warnings while running xgettext on validators.py

Sorry, I was reading too quickly. This really has got nothing to do with non-ASCII. It's just a (good) recommendation to use %(name)s formats instead of %s, but it's not a bug.

I've attached a patch to fix it, but I don't know if it's worth and what the general policy regarding formats in message id is, so I pass it on as "decision needed".

by Michael Radziej <mir@…>, 18 years ago

Attachment: ticket-3410.diff added

changes format to dict style

by Michael Radziej <mir@…>, 18 years ago

Attachment: ticket-3410.2.diff added

revised patch

comment:6 by Michael Radziej <mir@…>, 18 years ago

Note: You'll need to run

make-messages -l de 

after applying the patch.

comment:7 by mirrorballu2@…, 18 years ago

Summary: make-messages has warnings while running xgettext on validators.pymake-messages has warnings while running xgettext on validators.py and /contrib/admin/views/doc.py

Thanks for the patch, it worked. But...

errors happened while running xgettext on doc.py
./contrib/admin/views/doc.py:171: warning: '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.
./contrib/admin/views/doc.py:183: warning: '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.
./contrib/admin/views/doc.py:214: warning: '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.

by mirrorballu2@…, 18 years ago

Attachment: docpatch.diff added

A patch for doc.py

comment:8 by mirrorballu2@…, 18 years ago

Summary: make-messages has warnings while running xgettext on validators.py and /contrib/admin/views/doc.pymake-messages has warnings while running xgettext on validators.py, /contrib/admin/views/doc.py, and /utils/html.py

Now one last error:

errors happened while running xgettext on html.py
xgettext: Non-ASCII string at ./utils/html.py:10.
          Please specify the source encoding through --from-code.

comment:9 by ramiro <rm0 _at_ gmx.net>, 18 years ago

@mirrorballu2,

What version of xgettext are you using?. Mine is

xgettext (GNU gettext-tools) 0.14.4
Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Ulrich Drepper.

and I don't get any warnings in Django SVN trunk as today.

Just curious about if it is an older or a newer version of xgettext the one generating these (good) warnings.

comment:10 by mirrorballu2@…, 18 years ago

It's a newer version.

xgettext (GNU gettext-tools) 0.15
Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Ulrich Drepper.

comment:11 by Malcolm Tredinnick, 18 years ago

Triage Stage: Design decision neededReady for checkin

Why is this in "design decision needed"? Looks like an oversight, because the patch looks perfect (you cannot use positional args in translated strings, so they should be fixed). I'm going to break with protocol slightly and move this ahead a couple of steps in the production line.

The problem with working with multiple versions of xgettext is a separate issue and is a source of never-ending teeth grinding for people working with the gettext tools across different versions. That should be a separate ticket if it really is a problem.

comment:12 by Malcolm Tredinnick, 18 years ago

Triage Stage: Ready for checkinDesign decision needed

Looking over this with my brain turned on, I now see why Michael wanted a call made on this one. It's only generating a warning, not an error. I suspect it's still the right thing to do, to make this change, but I'm going to hold off for a little while until I look at whether we are being consistent throughout Django (I suspect we are because otherwise there would be more warnings). Then I'll update i18n.txt as well.

comment:13 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [4704]) Fixed #3410 -- Edited a few i18n markups for completeness and to remove some
warnings from recent gettext versions. Refs #3704. Thanks, Michael Radziej,
mirrorballu2@… and baptiste.goupil@….

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