Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

Internationalization of ordinal numbers

Thread view: 
Chris Smith - 14 May 2005 15:48 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.