1. Full locale support now in SVN!
- Posted by Jeremy Cowgar <jeremy at c??gar.com> May 05, 2008
- 844 views
Wow, it's finally working! We can now format date/time values, money, numbers and finally also message translation. Instead of going with an INI file, I went with the same format that gettext uses, the po file because there are many nice editors (not text editors but translation tools) for .po files. There are also text editors for the po format, as it is a simple text file. So, here's an example program: ---- File: po/en_US.po # English language file for greeter app hello Hello world World greeting %s, %s! ---- File: po/es_MX.po # Spanish language file for greeter app hello Hola world Mundo greeting %s, %s! ---- File: greeter.ex
include locale.e as l include datetime.e as d d:datetime now now = d:now() l:set_po_path("po") l:set("en_US") printf(1, "Date: %s\n", {l:datetime("%A, %B %d, %Y", now)}) printf(1, "Average car price: %s\n", {l:money(22652)}) printf(1, "Population: %s\n", {l:number(10000)}) printf(1, l:w("greeting"), {l:w("hello"), l:w("world")}) puts(1, "\n") l:set("es_MX") printf(1, "Date: %s\n", {l:datetime("%A, %B %d, %Y", now)}) printf(1, "Average car price: %s\n", {l:money(22652)}) printf(1, "Population: %s\n", {l:number(10000)}) printf(1, l:w("greeting"), {l:w("hello"), l:w("world")})
---- Output: Date: Sunday, May 04, 2008 Average car price: $22,652.00 Population: 10,000 Hello, World! Date: domingo, mayo 04, 2008 Average car price: $22,652.00 Population: 10,000 Hola, Mundo! ---- So, that's it. Now, I do have one more problem that many other systems do not address and maybe they do not because it's a very rare case? The problem is in the example of Hello, World!. Some languages may say who they are greeting first, like: World Hello! or something like that. In this situation, our localization will not work. As it is positional ("%s, %s!"). Any thoughts from someone better at localizing apps than I am? Oh, I know the date/time, money, number formatting did not change, but it's the same for English and Spanish... here's output if the locale is changed to de_DE: Date: Sonntag, Mai 04, 2008 Average car price: 1.020,50 EUR Population: 10.000 -- Jeremy Cowgar http://jeremy.cowgar.com
2. Re: Full locale support now in SVN!
- Posted by Kat <KAT12 at coosa?s.ne?> May 05, 2008
- 771 views
Jeremy Cowgar wrote: > > Wow, it's finally working! We can now format date/time values, money, numbers > and finally also message translation. > > Instead of going with an INI file, I went with the same format that gettext > uses, the po file because there are many nice editors (not text editors but > translation tools) for .po files. There are also text editors for the po > format, > as it is a simple text file. So, here's an example program: > > ---- File: po/en_US.po > # English language file for greeter app > hello Hello > world World > greeting %s, %s! > > ---- File: po/es_MX.po > # Spanish language file for greeter app > hello Hola > world Mundo > greeting %s, %s! > > ---- File: greeter.ex > }}} <eucode> > include locale.e as l > include datetime.e as d > > d:datetime now > now = d:now() > > l:set_po_path("po") > l:set("en_US") > printf(1, "Date: %s\n", {l:datetime("%A, %B %d, %Y", now)}) > printf(1, "Average car price: %s\n", {l:money(22652)}) > printf(1, "Population: %s\n", {l:number(10000)}) > printf(1, l:w("greeting"), {l:w("hello"), l:w("world")}) > puts(1, "\n") > > l:set("es_MX") > printf(1, "Date: %s\n", {l:datetime("%A, %B %d, %Y", now)}) > printf(1, "Average car price: %s\n", {l:money(22652)}) > printf(1, "Population: %s\n", {l:number(10000)}) > printf(1, l:w("greeting"), {l:w("hello"), l:w("world")}) > </eucode> {{{ > > ---- Output: > Date: Sunday, May 04, 2008 > Average car price: $22,652.00 > Population: 10,000 > Hello, World! > > Date: domingo, mayo 04, 2008 > Average car price: $22,652.00 > Population: 10,000 > Hola, Mundo! > ---- > > So, that's it. Now, I do have one more problem that many other systems do not > address and maybe they do not because it's a very rare case? The problem is > in the example of Hello, World!. Some languages may say who they are greeting > first, like: World Hello! or something like that. In this situation, our > localization > will not work. As it is positional ("%s, %s!"). > > Any thoughts from someone better at localizing apps than I am? I suggest again that the users in those locales submit the translations. They'd know (more than we would) what's appropriate. As for a program that automagically changes word order in any given sentence, well, that would be a great translation program, and beyond doing free. Unless you know native speakers to volunteer in all those locales. I once considered having Tiggr learn by reading pages in other languages, when good english translations exist, but the signal:noise ratio is too high online. As much as 90% of unknown user submitted posts are trash, as far as language use and factual data content is concerned. Kat
3. Re: Full locale support now in SVN!
- Posted by Jeremy Cowgar <jeremy at cowga??com> May 05, 2008
- 784 views
Kat wrote: > > I suggest again that the users in those locales submit the translations. > They'd > know (more than we would) what's appropriate. As for a program that > automagically > changes word order in any given sentence, well, that would be a great > translation > program, and beyond doing free. Unless you know native speakers to volunteer > in all those locales. I once considered having Tiggr learn by reading pages > in other languages, when good english translations exist, but the signal:noise > ratio is too high online. As much as 90% of unknown user submitted posts are > trash, as far as language use and factual data content is concerned. > Yes, the author of the application will be responsible to create their own language files for messages used in his/her app. However, in one language it may say Hello, World, while in another World, Hello. I was thinking maybe something like this would work? ---- en_US.po file message = $1%s, $2%s! ---- SomeOther.po file message = $2%s $1%s!
include locale.e as l --- init code puts(1, l:translate("message", {l:w("hello"), l:w("world")}))
So... translate would take parameters from the sequence sent in a positional order, possibly just reorder them and send the remainder %s %s! to sprintf. Just thinking aloud. -- Jeremy Cowgar http://jeremy.cowgar.com
4. Re: Full locale support now in SVN!
- Posted by Kat <KAT12 at coo?ahs?net> May 05, 2008
- 729 views
Jeremy Cowgar wrote: > > Kat wrote: > > > > I suggest again that the users in those locales submit the translations. > > They'd > > know (more than we would) what's appropriate. As for a program that > > automagically > > changes word order in any given sentence, well, that would be a great > > translation > > program, and beyond doing free. Unless you know native speakers to volunteer > > in all those locales. I once considered having Tiggr learn by reading pages > > in other languages, when good english translations exist, but the > > signal:noise > > ratio is too high online. As much as 90% of unknown user submitted posts are > > trash, as far as language use and factual data content is concerned. > > > > Yes, the author of the application will be responsible to create their own > language > files for messages used in his/her app. However, in one language it may say > Hello, World, while in another World, Hello. > > I was thinking maybe something like this would work? > > ---- en_US.po file > message = $1%s, $2%s! > > ---- SomeOther.po file > message = $2%s $1%s! > > }}} <eucode> > include locale.e as l > --- init code > puts(1, l:translate("message", {l:w("hello"), l:w("world")})) > </eucode> {{{ > > So... translate would take parameters from the sequence sent in a positional > order, possibly just reorder them and send the remainder %s %s! to sprintf. But you just cannot do that. fly paper = sticky paper to trap flies paper fly = an origami insect replicant hard drive = you know... drive hard = you prolly know too ... egg roll = roll egg = etc... Kat
5. Re: Full locale support now in SVN!
- Posted by CChris <christian.cuvier at agri?u?ture.gouv.fr> May 05, 2008
- 724 views
Jeremy Cowgar wrote: > > Kat wrote: > > > > I suggest again that the users in those locales submit the translations. > > They'd > > know (more than we would) what's appropriate. As for a program that > > automagically > > changes word order in any given sentence, well, that would be a great > > translation > > program, and beyond doing free. Unless you know native speakers to volunteer > > in all those locales. I once considered having Tiggr learn by reading pages > > in other languages, when good english translations exist, but the > > signal:noise > > ratio is too high online. As much as 90% of unknown user submitted posts are > > trash, as far as language use and factual data content is concerned. > > > > Yes, the author of the application will be responsible to create their own > language > files for messages used in his/her app. However, in one language it may say > Hello, World, while in another World, Hello. > > I was thinking maybe something like this would work? > > ---- en_US.po file > message = $1%s, $2%s! > > ---- SomeOther.po file > message = $2%s $1%s! > > }}} <eucode> > include locale.e as l > --- init code > puts(1, l:translate("message", {l:w("hello"), l:w("world")})) > </eucode> {{{ > > So... translate would take parameters from the sequence sent in a positional > order, possibly just reorder them and send the remainder %s %s! to sprintf. > > Just thinking aloud. > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> Your scheme doesn't even take care of the following. Even in the extremely simple "Hllo, World!" example. In spanish, sentences that end with an emphasis mark (!) start with an inverted emphasis mark (¡Hola, Mundo!). Changing word order just doesn't help. Completely agreeing with you, Kat. CChris
6. Re: Full locale support now in SVN!
- Posted by Jeremy Cowgar <jeremy at cowga?.co?> May 05, 2008
- 745 views
CChris wrote: > > Your scheme doesn't even take care of the following. Even in the extremely > simple > "Hllo, World!" example. In spanish, sentences that end with an emphasis mark > (!) start with an inverted emphasis mark (¡Hola, Mundo!). Changing word order > just doesn't help. > Completely agreeing with you, Kat. > The scheme does support it just fine. -- English.po hello Hello world World message=$1%s, $2%s! ---- Spanish.po hello Hola world Mundo message=!$2%s $1%s(!)
l:set("English") puts(1, l:translate("message", {l:w("hello"), l:w("world")})) l:set("Spanish") puts(1, l:translate("message", {l:w("hello"), l:w("world")}))
---- Output: Hello, World! !Mundo, Hola(!) -- Jeremy Cowgar http://jeremy.cowgar.com
7. Re: Full locale support now in SVN!
- Posted by Jeremy Cowgar <jeremy at cow?a?.com> May 05, 2008
- 744 views
Kat wrote: > > > But you just cannot do that. > > fly paper = sticky paper to trap flies > paper fly = an origami insect replicant > > hard drive = you know... > drive hard = you prolly know too ... > > egg roll = > roll egg = > I'm not seeing where any of this is a problem. Your keys would not change. It's the text after the keys that change. Also, please note, I modeled this after gettext which is about the standard in localization, however, they do not support the word re-ordering as I have mentioned. -- Jeremy Cowgar http://jeremy.cowgar.com