Re: [Sugar-devel] internationalization: homonym handling in genpot?
On 11.09.2010, at 04:43, Erik Blankinship wrote: If it doesn't work, I guess you could also directly use the low-level encoding of context: label1 = _(device_icon_menu\x04Remove) 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? Yes, everything up to the EOT character needs to be stripped. - Bert - ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
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/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
Hi Erik, On 11 Sep 2010, at 03:31, Erik Blankinship wrote: Just to make sure I understand your solution, if the activity is run in an untranslated language, won't Arrow|Bow be displayed? Yes. However I was thinking that you could go create/edit the po/en.po file and add in those string corrections, This assumes that English will be the default fall back language in a translation is not available? Is this always the case? That's a good point, yea it would fallback to the mangled string version if none of po domain files matched. I guess you will need to implement your own little version of _() that: - accepts two parameters, a context and string - joins them and sends the mangled string through the usual gettext call - test to see if gettext has returned the same mangled string, if so return only the string you were given Regards, --Gary ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
Any suggestions? Do I need to hand roll all of my .po files before getting them translated? [er...@localhost po]$ ls POTFILES.in WeDo.pot [er...@localhost po]$ msginit -l es WeDo.pot:25: context separator EOT within string WeDo.pot:29: context separator EOT within string WeDo.pot:33: context separator EOT within string WeDo.pot:37: context separator EOT within string WeDo.pot:41: context separator EOT within string WeDo.pot:45: context separator EOT within string WeDo.pot:49: context separator EOT within string WeDo.pot:53: context separator EOT within string WeDo.pot:57: context separator EOT within string WeDo.pot:61: context separator EOT within string WeDo.pot:65: context separator EOT within string WeDo.pot:69: context separator EOT within string WeDo.pot:73: context separator EOT within string WeDo.pot:77: context separator EOT within string WeDo.pot:81: context separator EOT within string WeDo.pot:85: context separator EOT within string WeDo.pot:89: context separator EOT within string WeDo.pot:93: context separator EOT within string WeDo.pot:97: context separator EOT within string WeDo.pot:101: context separator EOT within string msginit: too many errors, aborting [er...@localhost po]$ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
switched to /x02 and that works just fine :-) ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
On Fri, Sep 10, 2010 at 4:36 PM, Erik Blankinship er...@mediamods.com wrote: (maybe there is genpot list where this message is more apropos? Sorry, genpot is opaque to me.) My activity has two identical-in-english strings (homonyms) which need translating, but have two different meanings depending on context in an activity. How should I flag genpot that these are two different strings which might require different translations? #TRANS: bow and arrow activeDisplay = _(Bow) #TRANS: the front of a ship istrDisplay = _(Bow) Currently python setup.py genpot produces this output, making it impossible for the translator to handle both meanings differently: #. 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: http://bugs.python.org/issue2504 Bernie is subscribed to the bug, so he might know how we are dealing with this in other activities, adding him to cc. Marco ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
Hi Erik, On 10 Sep 2010, at 16:36, Erik Blankinship er...@mediamods.com wrote: (maybe there is genpot list where this message is more apropos? Sorry, genpot is opaque to me.) My activity has two identical-in-english strings (homonyms) which need translating, but have two different meanings depending on context in an activity. How should I flag genpot that these are two different strings which might require different translations? #TRANS: bow and arrow activeDisplay = _(Bow) #TRANS: the front of a ship istrDisplay = _(Bow) Ooh interesting, not bumped into this need myself yet, but (as a cheat) it strikes me that gettext is using the given strings as IDs for its string lookups so you could replace your strings with _(Arrow|Bow) and _(Ship|Bow), then make sure the pot file actually has the correct Bow msgstr set. I think though what your really looking for is context support but have not tinkered other than a few min googling: http://bugs.python.org/issue2504 If the Python workflow is working/there, and I haven't tested... you'd get extra msgctxt entry in the pot file containing your extra context argument supplied with the string allowing for disambiguation. Interesting questing, hope that helped :) Regards, --Gary Currently python setup.py genpot produces this output, making it impossible for the translator to handle both meanings differently: #. TRANS: bow and arrow #. TRANS: the front of a ship #: constants.py:35 #: constants.py:38 msgid Bow msgstr ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
#TRANS: bow and arrow activeDisplay = _(Bow) #TRANS: the front of a ship istrDisplay = _(Bow) Ooh interesting, not bumped into this need myself yet, but (as a cheat) it strikes me that gettext is using the given strings as IDs for its string lookups so you could replace your strings with _(Arrow|Bow) and _(Ship|Bow), then make sure the pot file actually has the correct Bow msgstr set. I think though what your really looking for is context support but have not tinkered other than a few min googling: Just to make sure I understand your solution, if the activity is run in an untranslated language, won't Arrow|Bow be displayed? I was thinking to use bow and bow , and them trim all white space before displaying in an activity. ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
On Fri, Sep 10, 2010 at 1:17 PM, Erik Blankinship er...@mediamods.com wrote: #TRANS: bow and arrow activeDisplay = _(Bow) #TRANS: the front of a ship istrDisplay = _(Bow) Ooh interesting, not bumped into this need myself yet, but (as a cheat) it strikes me that gettext is using the given strings as IDs for its string lookups so you could replace your strings with _(Arrow|Bow) and _(Ship|Bow), then make sure the pot file actually has the correct Bow msgstr set. I think though what your really looking for is context support but have not tinkered other than a few min googling: Just to make sure I understand your solution, if the activity is run in an untranslated language, won't Arrow|Bow be displayed? I think you can fill in (by hand) the msgstr in your POT file and it will do the right thing for untranslated languages. -walter I was thinking to use bow and bow , and them trim all white space before displaying in an activity. ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel -- Walter Bender Sugar Labs http://www.sugarlabs.org ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
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: http://bugs.python.org/issue2504 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/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
Hi Erik, On 10 Sep 2010, at 18:17, Erik Blankinship er...@mediamods.com wrote: #TRANS: bow and arrow activeDisplay = _(Bow) #TRANS: the front of a ship istrDisplay = _(Bow) Ooh interesting, not bumped into this need myself yet, but (as a cheat) it strikes me that gettext is using the given strings as IDs for its string lookups so you could replace your strings with _(Arrow|Bow) and _(Ship|Bow), then make sure the pot file actually has the correct Bow msgstr set. I think though what your really looking for is context support but have not tinkered other than a few min googling: Just to make sure I understand your solution, if the activity is run in an untranslated language, won't Arrow|Bow be displayed? Yes. However I was thinking that you could go create/edit the po/en.po file and add in those string corrections, then run './setup build' to generate the locale .mo files. I've just tested here, I guess making sure you have a clear comment so the translators are not too confused by this approach would be the critical step. FWIW in case you are using a Soas image, './setup build' is giving me a nasty traceback on two different images (Mirabell and a recent F14 beta build). Worked just fine in the latest official 852 build from OLPC on an XO-1. Was just going to give a dextrose XO-1 build a go as well, but am away from home and net connection is slow here, will be tomorrow before I can test that. Regards, --Gary I was thinking to use bow and bow , and them trim all white space before displaying in an activity. ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
I think you can fill in (by hand) the msgstr in your POT file and it will do the right thing for untranslated languages. Alas, this does not seem to work. .pot files are, evidently, just the translation template. As far as I can tell the untranslated language gets what's in your python source. ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
Just to make sure I understand your solution, if the activity is run in an untranslated language, won't Arrow|Bow be displayed? Yes. However I was thinking that you could go create/edit the po/en.po file and add in those string corrections, This assumes that English will be the default fall back language in a translation is not available? Is this always the case? ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
Re: [Sugar-devel] internationalization: homonym handling in genpot?
If it doesn't work, I guess you could also directly use the low-level encoding of context: label1 = _(device_icon_menu\x04Remove) 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? ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel