Loading...

March 29, 2011

Grails Goodness: Splitting i18n Message Bundles

Grails supports internationalization out of the box. In the directory grails-app/i18n we find a messages.properties with default Grails messages. We only have to make a new properties file where the name ends with the locale to add messages for another locale to our application.

But we are not restricted to the basename messages for our message bundles. We can use any name as long as we place the file in the grails-app/i18n directory. For example we can create a file views.properties to store messages related to the Groovy Server Pages and a file validation.properties with messages related to validation of domain objects. And if we want specific messages for the Dutch locale for example we create views_nl.properites and validation_nl.properties.