Translatable strings for 1st/2nd/3rd/nth
Does anyone have suggestions for creating translatable strings for rankings? I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution. Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric. Thoughts? Thanks, Chris
The t( ) mechanism is very simple but in a few cases like the one you mentioned (1st, 2nd, 3rd, nth...) it does create some issues that make it impossible to have a correct translation. Another case is for months translation, where the abbreviation for "May" is "May", so that in languages where that month is longer (like in Italian "Maggio") there can't be both a full month name and an abbreviation. One option would be change the t( ) mechanism so that its input is a key instead of the English translation. In most cases, the key would be the English translation as it currently is, but it would also be possible to set the key of a message to be different from the English value. For the example mentioned above we would have: 'may_short' => ('en' -> 'May', 'it' -> 'Maggio' ) 'may_long' => ('en' -> 'May', 'it' -> 'Maggio' ) This change would make drupal's translation mechanism less English-centric. There's of course some issues with these modifications, mainly knowing what the best way to specify keys/messages is, but it would probably make things more adaptable languages other than English, which seems to be one of the big focuses of the 6.x release. Florian On 5/2/07, Chris Kennedy <chrisken@mail.utexas.edu> wrote:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Thanks, Chris
Florian Loretan wrote:
The t( ) mechanism is very simple but in a few cases like the one you mentioned (1st, 2nd, 3rd, nth...) it does create some issues that make it impossible to have a correct translation. Another case is for months translation, where the abbreviation for "May" is "May", so that in languages where that month is longer (like in Italian "Maggio") there can't be both a full month name and an abbreviation.
One option would be change the t( ) mechanism so that its input is a key instead of the English translation. In most cases, the key would be the English translation as it currently is, but it would also be possible to set the key of a message to be different from the English value. For the example mentioned above we would have:
'may_short' => ('en' -> 'May', 'it' -> 'Maggio' ) 'may_long' => ('en' -> 'May', 'it' -> 'Maggio' )
This change would make drupal's translation mechanism less English-centric. There's of course some issues with these modifications, mainly knowing what the best way to specify keys/messages is, but it would probably make things more adaptable languages other than English, which seems to be one of the big focuses of the 6.x release.
How would that map to the gettext toolchain we/you use? Gabor
Quoting Chris Kennedy <chrisken@mail.utexas.edu>:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else. Earnie
Earnie Boyd wrote:
Quoting Chris Kennedy <chrisken@mail.utexas.edu>:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else.
Earnie, how would that SQL table work for translations? Different languages need very different suffixes. I don't see what table structure you envision here. Gabor
Quoting Gabor Hojtsy <gabor@hojtsy.hu>:
Earnie Boyd wrote:
Quoting Chris Kennedy <chrisken@mail.utexas.edu>:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else.
Earnie, how would that SQL table work for translations? Different languages need very different suffixes. I don't see what table structure you envision here.
Chris was looking for "simple" and and realized his needs are "English-centric" but was wanting some way to possibly support simple translation. int|locale|string 1|en|st 2|en|nd So now he creates a function to look for the passed int value and locale and appends the suffix or some administrated set default. No it doesn't fit all scenarios. Frankly, I would suggest using t('first'), t('second'), etc instead of the lazy symbols. Earnie
On 03.05.2007, at 21:19, Earnie Boyd wrote:
Chris was looking for "simple" and and realized his needs are "English-centric" but was wanting some way to possibly support simple translation.
No, he is looking for the opposite. Konstantin Käfer – http://kkaefer.com/
Earnie Boyd wrote:
Earnie, how would that SQL table work for translations? Different languages need very different suffixes. I don't see what table structure you envision here.
Chris was looking for "simple" and and realized his needs are "English-centric" but was wanting some way to possibly support simple translation.
int|locale|string 1|en|st 2|en|nd
So now he creates a function to look for the passed int value and locale and appends the suffix or some administrated set default. No it doesn't fit all scenarios.
Frankly, I would suggest using t('first'), t('second'), etc instead of the lazy symbols.
Yes, the problem with the above table that it is hardly (if at all) fits into the gettext based translation toolset translators are using. Gabor
Gabor Hojtsy wrote:
Earnie Boyd wrote:
Earnie, how would that SQL table work for translations? Different languages need very different suffixes. I don't see what table structure you envision here.
Chris was looking for "simple" and and realized his needs are "English-centric" but was wanting some way to possibly support simple translation.
int|locale|string 1|en|st 2|en|nd
So now he creates a function to look for the passed int value and locale and appends the suffix or some administrated set default. No it doesn't fit all scenarios.
Frankly, I would suggest using t('first'), t('second'), etc instead of the lazy symbols.
Yes, the problem with the above table that it is hardly (if at all) fits into the gettext based translation toolset translators are using. Yeah, gettext is the wrong tool for this this job. A "locale" library, or a numerical/calendaric library is what needs to get used here. The whole concept of doing ordinal numbers by tacking on "st", "nd" is too specific to English to practically handle any other way.
For a really good explanation of some of the reasons why this is so, it's worth reading this tutorial from Sun: http://java.sun.com/docs/books/tutorial/i18n/format/index.html While the APIs are Java specific, the issues apply to any kind of coding you want to work for more than one human language or script.
Gabor
I doubt if the "th" concept even exists in many languages. Not being a language scholar I can't give explicit examples. It is usually possible to word messages so you don't use the "th" concept. This seems like a better approach. -----Original Message----- From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of Earnie Boyd Sent: Thursday, May 03, 2007 8:56 AM To: development@drupal.org Subject: Re: [development] Translatable strings for 1st/2nd/3rd/nth Quoting Chris Kennedy <chrisken@mail.utexas.edu>:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else. Earnie -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.6.2/785 - Release Date: 5/2/2007 2:16 PM
I can tell you that languages can be so different that even simple assumptions are no longer valid. For example, most languages in Europe have a singular and plural, at least those of Indo European origin. For English, adding "s" or "es" is sufficient in most cases, and if you want to do a porter stemmer, you take that out (oversimplifying, but you get the idea). In Arabic, there is singular, dual and plural. And then there is masculine and feminine version of each of those. So the assumptions made for English no longer carries over well to Arabic. On 5/3/07, Walt Daniels <wdlists@optonline.net> wrote:
I doubt if the "th" concept even exists in many languages. Not being a language scholar I can't give explicit examples. It is usually possible to word messages so you don't use the "th" concept. This seems like a better approach.
-----Original Message----- From: development-bounces@drupal.org [mailto: development-bounces@drupal.org] On Behalf Of Earnie Boyd Sent: Thursday, May 03, 2007 8:56 AM To: development@drupal.org Subject: Re: [development] Translatable strings for 1st/2nd/3rd/nth
Quoting Chris Kennedy <chrisken@mail.utexas.edu>:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else.
Earnie
-- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.467 / Virus Database: 269.6.2/785 - Release Date: 5/2/2007 2:16 PM
-- 2bits.com http://2bits.com Drupal development, customization and consulting.
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else.
This doesn't work like you imagine it: Different language have completely different concepts of ordinal numbers. In some cases, they even depend on the genus (other languages have > 1 grammatical genus) of the word. In French for example, you say "mon 1er chat" (my 1st cat) but "ma 1ère souris" (my first mouse). In German, the short form of ordinal numbers is constructed by simply adding a dot to the number: "meine 1. Katze" and "meine 1. Maus". Different genera are already a problem with translation variables, for example, take the string: "Your %post has been created." where % post is a content type name. Now the problem is, that "Artikel" (= article) is masculine while "Umfrage" (= poll) is of female gender. You can't write "Der %post wurde erstellt." because "Der" is the masculine article while "Umfrage" would require "Die" instead of "Der". Konstantin Käfer – http://kkaefer.com/
Quoting Konstantin Käfer <kkaefer@gmail.com>:
Are there existing math libraries that might help? Simple solution might be a SQL table that you add the exceptions to 'th' to. So the translation for 1 would contain 1st and the translation for 2 would 2nd and your 'th' default would be suffixed for everything else.
This doesn't work like you imagine it: Different language have completely different concepts of ordinal numbers. In some cases, they even depend on the genus (other languages have > 1 grammatical genus) of the word. In French for example, you say "mon 1er chat" (my 1st cat) but "ma 1ère souris" (my first mouse). In German, the short form of ordinal numbers is constructed by simply adding a dot to the number: "meine 1. Katze" and "meine 1. Maus".
The OP had said that 1st, 2nd, etc was English oriented. I gave an English oriented solution. My first opinion was to use the full English word, i.e. first, second, etc and avoid the need for the specialized translation. Yes, I am stupid when it comes to other language vernacular.
Different genera are already a problem with translation variables, for example, take the string: "Your %post has been created." where % post is a content type name. Now the problem is, that "Artikel" (= article) is masculine while "Umfrage" (= poll) is of female gender. You can't write "Der %post wurde erstellt." because "Der" is the masculine article while "Umfrage" would require "Die" instead of "Der".
I really appreciate those that are forced to learn English to communicate with the rest of the world. I do understand the difficulties and I am amazed at how much of the world is able to communicate with me. One of the best stories I have heard is one set of parents who knew 7 different languages and forced there children to speak a different language on the different days of the week. If we typical Americans had to actually learn and _use_ some other language to communicate with others we might be a better country. Earnie
The OP had said that 1st, 2nd, etc was English oriented. I gave an English oriented solution. My first opinion was to use the full English word, i.e. first, second, etc and avoid the need for the specialized translation. Yes, I am stupid when it comes to other language vernacular.
Chris said that he realizes "that this will not work for extractor.php purposes and is English-centric.", he did not say that he wants an English oriented solution. Konstantin Käfer – http://kkaefer.com/
Generally speaking, you want to use a general purpose date or number formatting libraries for this. I'm not sure how good the PHP library functions are for this (I know more about the Java libraries, which are pretty good). Also, you should not be looking at how to localize things like "st" or "nd": you should be localizing the formats themselves, since dates -- where you most often use this in English -- have very different formats going even from country to country, as well as from language to language. You probably wouldn't consider writing your own encryption library. You probably don't want to be writing a library like this, either. So I think you have the wrong approach here, unless you intend to write a general purpose I18n library on the level of the Java libraries, which is a task for an organization on the scale of IBM or Sun. What exactly are you trying to do here? Rob Rob Thorne Torenware Networks Chris Kennedy wrote:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Thanks, Chris
Yes, I have some suggestion, just I dont know whether for Drupal 6 or next versions.. We need to expand the downloadable translations from being only .po files to something that may include also some code, maybe a language icon, maybe some theme functions.... (language packs) And there should be something like a callback in locale function locale(...) { if (function_exists("locale_language_$locale")) ... ... so we'll be able to customize translations for any language, adding whatever code we need, using the current static strings translations as a fallback ... or using some web translation service to provide translations when there's none available... So, basically, we need to be able to hook some function calls into all language related functions. By the way, I think we are heading in that direction with the -soon to be posted- patch for user string translations, which is part of the Drupal6/i18n development. Chris Kennedy wrote:
Does anyone have suggestions for creating translatable strings for rankings?
I need to generate strings for 1st/2nd/3rd/4th/etc. ideally without a limit, but don't know of a simple translatable solution.
Right now I just have individual t() strings for 1st/2nd/3rd, then a blanket t($i .'th') for the rest, under the untested theory that translators could manually add translations for Nth into their .po files up to a reasonable limit. I realize that this will not work for extractor.php purposes and is English-centric.
Thoughts?
Thanks, Chris
We need to expand the downloadable translations from being only .po files to something that may include also some code, maybe a language icon, maybe some theme functions.... (language packs)
I thought about that, too, but I'm not really comfortable letting translators write code that is executed in my Drupal installation. Maybe that's just me, but I have a gut feeling about it. But even such functions leave us with the gender problem.
... or using some web translation service to provide translations when there's none available...
Is that serious or a joke? Konstantin Käfer – http://kkaefer.com/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Konstantin Käfer schrieb:
We need to expand the downloadable translations from being only .po files to something that may include also some code, maybe a language icon, maybe some theme functions.... (language packs)
I thought about that, too, but I'm not really comfortable letting translators write code that is executed in my Drupal installation. Maybe that's just me, but I have a gut feeling about it. But even such functions leave us with the gender problem.
... or using some web translation service to provide translations when there's none available...
Is that serious or a joke?
I wasn't sure either... Webservices are the doom of performance. Cheers, Gerhard -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGOlfPfg6TFvELooQRAj7IAKC8FO3zMsUA3hYfHpvAef0LOaz1ZgCePo6L ojCjyCQEvaQ2MpuY0/dmavw= =R17N -----END PGP SIGNATURE-----
Gerhard Killesreiter wrote:
Konstantin Käfer schrieb:
We need to expand the downloadable translations from being only .po files to something that may include also some code, maybe a language icon, maybe some theme functions.... (language packs) I thought about that, too, but I'm not really comfortable letting translators write code that is executed in my Drupal installation. Maybe that's just me, but I have a gut feeling about it. But even such functions leave us with the gender problem.
... or using some web translation service to provide translations when there's none available... Is that serious or a joke?
I wasn't sure either... Webservices are the doom of performance. It's serious.
One time translation of a string using a web service has much better performance than a human translator. -- of course, you'd save the translation to your local database so you don't need to use it again for that string :p
Cheers, Gerhard
participants (10)
-
Chris Kennedy -
Earnie Boyd -
Florian Loretan -
Gabor Hojtsy -
Gerhard Killesreiter -
Jose A. Reyero -
Khalid Baheyeldin -
Konstantin Käfer -
Rob Thorne -
Walt Daniels