[Sugar-devel] internationalization: homonym handling in genpot?
bernie at codewiz.org
Fri Sep 10 15:05:32 EDT 2010
On Fri, 2010-09-10 at 17:59 +0100, Marco Pesenti Gritti wrote:
> > #. TRANS: bow and arrow
> > #. TRANS: the front of a ship
> > #: constants.py:35
> > #: constants.py:38
> > msgid "Bow"
> > msgstr ""
> It looks like python doesn't support contexts yet:
> Bernie is subscribed to the bug, so he might know how we are dealing
> with this in other activities, adding him to cc.
This should be a working implementation of pgettext for Python:
def pgettext(ctx, msg):
return gettext(ctx + "\x04" + msg)
It's used like so:
label1 = pgettext("device_icon_menu", "Remove")
label2 = pgettext("file_menu", "Remove")
So you can translate the first as "eject" and the second as "delete".
Now, I'm not sure whether the gettext command will recognize pgettext
when processing Python input, as it's not part of the gettext module.
If it doesn't work, I guess you could also directly use the low-level
encoding of context:
label1 = _("device_icon_menu\x04Remove")
// Bernie Innocenti - http://codewiz.org/
\X/ Sugar Labs - http://sugarlabs.org/
More information about the Sugar-devel