[Sugar-devel] internationalization: homonym handling in genpot?

Bernie Innocenti bernie at codewiz.org
Sat Sep 11 08:28:40 EDT 2010


On Fri, 2010-09-10 at 22:43 -0400, Erik Blankinship wrote:


>  label1 = _("device_icon_menu\x04Remove")
>  label2 = _("file_menu\x04Remove")
>
> Not surprisingly, this creates unique entries in the .pot file since
> they are two different strings, and then both can be translated.
>
> However, if the translation is not available, you get one messed up
> looking string.  Is there supposed to be a way to suppress the first
> half of that string when it is displayed with gettext?

It turns out that I was wrong... one can't directly use gettext() (aka
_()) to translate messages with context.

The pgettext() implementation I provided is also too simple. This
(untested) version should work:

 def pgettext(ctx, msg):
     translated = gettext(ctx + "\x04" + msg)
     if '\x04' in translated:
         return msg
     return translated

-- 
   // Bernie Innocenti - http://codewiz.org/
 \X/  Sugar Labs       - http://sugarlabs.org/



More information about the Sugar-devel mailing list