Internationalization of ordinal numbers

C

Chris Smith

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?

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
A

Adam Maass

Chris Smith said:
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:

.*=\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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top