Re: Format specifier (re)ordering in Python (was: String change for orca)



On Wed, Feb 11, 2009 at 09:37:20PM +0100, Wouter Bolsterlee wrote:
>   >>> 'the role is %(role)s and the level is %(level)d' % {'role': 'test', 'level': 3}
>   'the role is test and the level is 3'
> 
> If translators decide the order has to be changed, this will result in
> something like this:
> 
>   >>> 'the level is %(level)d and the role is %(role)s' % {'role': 'test', 'level': 3}
>   'the level is 3 and the role is test'
> 
> This approach works in all cases, even in the case that the two format
> specifiers are the same (e.g. both are numbers).
> 
> There is one downside though: translators MUST NOT translate the keywords

Isn't this checked by the msgfmt command? If not, it should be, IMHO.
Bug in gettext?

> ("level" and "role" in my case), since those are the keys used to lookup the
> value in the mapping passed to the % operator. But then, translators can
> just as well mess up format specifiers that are used in the traditional,
> positional way, e.g. by translating '%.3f' to %.0f', which will result in
> the fraction being removed upon display. So... a short translator notice
> should be fine to avoid this problem.

-- 
+-------------------------------------------+
| Marcel Telka   e-mail:   marcel telka sk  |
|                homepage: http://telka.sk/ |
|                jabber:   marcel jabber sk |
+-------------------------------------------+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]