Wednesday, May 25, 2005

Dealing with Compound messages during i18n

A compound message contains variable data. In the following list of compound messages, the variable data is in bold:

The disk named MyDisk contains 300 files.
The current balance of account #34-98-222 is $2,745.72.
405,390 people have visited your website since January 1, 1998.
Delete all files older than 120 days.

Such messages are always difficult to localize. Just picking up sub-strings from the properties files won't work and would be very cumbersome. In Java, there is a cool class named "MessageFormat" that can be used in such cases. The following link contains the tutorial:
http://java.sun.com/