Internationalization (i18n)

Waffle fully supports i18n via the org.codehaus.waffle.i18n.MessageResources interface and its ResourceBundle-based org.codehaus.waffle.i18n.DefaultMessageResources implementation. As customary in Waffle, the user may also provide their own implementation, eg interfacing to a more sophisticated CMS layer (refer to Pluggability).

Configuring MessageResources

Waffle is fully configurable via the org.codehaus.waffle.i18n.MessageResourcesConfiguration interface and, again, comes with a org.codehaus.waffle.i18n.DefaultMessageResourcesConfiguration which allows the user to be up and running in no time. The two elements of the configuration are:

  1. A resource URI (the default value is "ApplicationResources", as is also found in other web action frameworks).
  2. A locale (which defaults to the server default locale).
These two elements can either be configure by extending MessageResources: or directly in the Registrar:

Multiple ResourceBundles supported

As exemplified in the second configuration method above, the URI need not be a single bundle name: it can be a CVS-list of bundle names. This allows i18n to be implemented in a much more modular way, without having to duplicate resource messages. By default, the separator of the list is a comma (as expected), but can be overridden by extending the DefaultMessageResources: When multiple resource bundles are configured, they are merged into a single resource bundle using the last-entry-wins strategy. This means that the user can always resolve any potential conflicts arising from duplicate key entries in the merged bundles.