[GRASS-dev] xgettext grasswxpy issue

Glynn Clements glynn at gclements.plus.com
Sat Oct 11 22:59:36 EDT 2008


Markus Neteler wrote:

> just found this one while running "make pot" (GRASs 6.4.svn):
> 
> Generating grasswxpy...
> xgettext -k_ -o ./templates/grasswxpy.pot `find ../gui/wxpython -name
> '*.py' | xargs grep -l "_(\""`
> ../gui/wxpython/gui_modules/colorrules.py:391: 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,

391            self.cr_label.SetLabel(_('Enter raster cat values or percents (range = %d-%d)' %
392                                     (self.rast['min'], self.rast['max'])))

Note that this issue also arises in C: the use of e.g. "%1$d" in
format strings isn't part of C89, although it is in C99 and SUS.

It's almost invariably possible to come up with a form of wording
which preserves the original order, e.g. "(min=%d, max=%d)".

I would guess that this specific case might be an issue for
right-to-left languages (we do have a partial Arabic translation for
grassmods and grasslibs, but not grasswxpy).

If we want to eliminate the warning, the solution is:

            self.cr_label.SetLabel(_('Enter raster cat values or percents (range = %(min)d-%(min)d)' %
                                     dict(min = self.rast['min'], max = self.rast['max'])))

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list