Wednesday, October 26, 2005

ChoiceFormat

For those of you that are used to properties files and use it for i18n, in particular with frameworks like Struts, you must know the ChoiceFormat, from Java API. Very interesting for scenarios where you want to make minor adjustments to the text according to the value you receive. The example in MessageFormat is excellent to show you this:

"There {0,choice,1#is one file|1<are {0,number,integer} files}."


In this case, the English message is adjusted according to the value you get.
Post a Comment