[Sugar-devel] [PATCH 2/5] sl#2815: Localization fixes.

Chris Leonard cjlhomeaddress at gmail.com
Fri Jan 20 08:53:57 EST 2012


On Fri, Jan 20, 2012 at 8:31 AM, Gonzalo Odiard <gonzalo at laptop.org> wrote:
> The problem is the substitution of a single string to translate here:
>
>                 secondary_text = _('%(hour)d:%(min).2d remaining') % \
>                         {'hour': remaining_hourpart, 'min':
> remaining_minpart}
>
> by a concatenation here:
>
>                 time_value = '%(hour)d:%(min).2d ' % \
>                         {'hour': remaining_hourpart, 'min':
> remaining_minpart}
>                 secondary_text = time_value + _('remaining')
>
> The string to translate should be one, the the translator can reorder as
> needed.

I agree with Gonzalo, any concatenation is very bad i18n practice.  A
complete phrase can be properly translated to conform to the syntax of
any language.  I do not believe there is a need to change the string
itself, I would leave it as is.

>
> But the bug say "This string could use a developers comment clarifying what
> gets translated.
> It is often done incorrectly in our Pootle instance."
>
> I think he refer to add a line as:
>
> # TRANS: Remaining battery time.

I would probably suggest

# TRANS: do not translate %(hour)d:%(min).2d  it is a variable, only
translate the word "remaining"

What I commonly see is the local words for hour and minute inserted in
the variable, causing a printf error, whcih will break a software
build.

>
> This comment will be used by gettext and displayed in the pootle server to
> help the translators
>
> You can see one example here:
> http://git.sugarlabs.org/sugar/mainline/blobs/master/extensions/cpsection/updater/view.py#line381
>
> I am copying to Chris to confirm if this was the intention of the bug
> filled.
>
> Gonzalo


More information about the Sugar-devel mailing list