Code

Opened 7 years ago

Closed 7 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: master
Severity: Keywords: gettext
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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

Download all attachments as: .zip

Change History (16)

comment:1 Changed 7 years ago by Michael Radziej <mir@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from errors while running xgettext on validators.py to make-messages cannot deal with non-ASCII message ids
  • Triage Stage changed from Unreviewed to Design 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 Changed 7 years ago by anonymous

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

comment:3 Changed 7 years ago by anonymous

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 Changed 7 years ago by mirrorballu2@…

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 Changed 7 years ago by Michael Radziej <mir@…>

  • Has patch set
  • Summary changed from make-messages cannot deal with non-ASCII message ids to make-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".

Changed 7 years ago by Michael Radziej <mir@…>

changes format to dict style

Changed 7 years ago by Michael Radziej <mir@…>

revised patch

comment:6 Changed 7 years ago by Michael Radziej <mir@…>

Note: You'll need to run

make-messages -l de 

after applying the patch.

comment:7 Changed 7 years ago by mirrorballu2@…

  • Summary changed from make-messages has warnings while running xgettext on validators.py to make-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.

Changed 7 years ago by mirrorballu2@…

A patch for doc.py

comment:8 Changed 7 years ago by mirrorballu2@…

  • Summary changed from make-messages has warnings while running xgettext on validators.py and /contrib/admin/views/doc.py to make-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 Changed 7 years ago by ramiro <rm0 _at_ gmx.net>

@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 Changed 7 years ago by mirrorballu2@…

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 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Design decision needed to Ready 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 Changed 7 years ago by mtredinnick

  • Triage Stage changed from Ready for checkin to Design 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 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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@….

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.