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
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