Good morning,
I'm adding internationalization to an existing Java application, and
I've hit a wall. I need to translate ordinal numbers, as in 1st, 2nd,
3rd, etc. In the English version, the numbers are written with
ordinals, and a simple function to determine the suffix. Unfortunately,
I don't see an easy way to perform this task in other languages. I've
looked through NumberFormat and Google to no avail.
First question: is there an easy way to do this? If yes, please
disregard the remainder of this article.
Another programmer on this project is proposing that we should just
provide a simple rule-based language and let the translator specify the
scheme. The language would look something like this for English:
.*1.=\0th;.*1=\0st;.*2=\0nd;.*3=\0rd;.*=\0th
For German, as I understand it while not being a native German speaker,
it would be simpler:
.*=\0\.
Basically, this is a series of rules separated by semicolons. Each rule
consists of a pattern and a replacement separated by an equal sign. The
pattern is a Java regular expression, and the replacement is what it's
replaced with, and can contain subexpression references. Earlier rules
take precedence over later rules.
Second question: Does this seem to work well for all languages you know?
I'm fairly convinced that it does, but if you know any human language
where this doesn't work, please let me know.
Third question: Obviously, a translator isn't going to write these
expressions. They belong with the translation file, though. If you
were doing this work, would you include it in the .properties file, or
somewhere else?

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Adam Maass - 16 May 2005 04:52 GMT
> Another programmer on this project is proposing that we should just
> provide a simple rule-based language and let the translator specify the
> scheme. The language would look something like this for English:
>
> .*1.=\0th;.*1=\0st;.*2=\0nd;.*3=\0rd;.*=\0th
Careful, English has some oddities:
1st, 21st, 31st, etc,
but:
11th
> For German, as I understand it while not being a native German speaker,
> it would be simpler:
[quoted text clipped - 10 lines]
> I'm fairly convinced that it does, but if you know any human language
> where this doesn't work, please let me know.
I think I remember reading somewhere that the rules for forming ordinals in
Welsh are rather complex. But of course, that's only a half-remembered
notion.
Lāʻie Techie - 25 May 2005 07:15 GMT
> Second question: Does this seem to work well for all languages you know?
> I'm fairly convinced that it does, but if you know any human language
> where this doesn't work, please let me know.
Most Latin languages have different ordinals for masculine and feminine
objects. For Spanish and Portuguese use a superscript o for masculine or
a superscripted a for feminine.
"2a cara" (second face) != "2o cara" (second guy)
> Third question: Obviously, a translator isn't going to write these
> expressions. They belong with the translation file, though. If you were
> doing this work, would you include it in the .properties file, or
> somewhere else?
Since they vary by language, they belong in a ResourceBundle (most often a
.properties file)
HTH,
La'ie Techie