Alex Rivera | Logout

Is there standard way in grails to manage plurals in international strings from property files?

Asked 2011-04-22T19:30:08.883
14

Using the plugin for international, is there a "proper" way to pluralize words dynamically, or select the plural version of a property?

Edit
Report

1 Answer

23

You can use an embedded ChoiceFormat in the i18n message. Using an example from the java.text.MessageFormat Javadocs you could define something like:

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

Then in your GSP:

<g:message code="numfiles.message" args="[numfiles]"/>

Where numfiles is an integer value.

answered 2011-08-13T21:25:20.650

Your Answer