Chrysalis Internationalization

Chrysalis internationalization is tightly integrated with the rest of the framework. The core internationalization package is org.chwf.i18n, but other Chrysalis packages also support internationalization:

  • The org.chwf.config package supports searches for localized configuration files.
  • The org.chwf.converter package localizes string to value conversions.

User Locale

The org.chwf.i18n.UserLocale provides a central point to manage the user's locale.

  • The UserLocale.getLocale() method retrieves the user locale, using the System locale if no user locale is defined.
  • The UserLocale.setLocale() sets the user locale, ultimately storing it in the user Session.

Because these methods are static, the Chrysalis framework does not need to explicitly pass the user's java.util.Locale object between application layers.

Localized Configurations

The Chrysalis configuration library employees a search algorithm similar to that used by the java.util.ResourceBundle class. In addition to the common configuration file, Chrysalis also searches localized files for configuration information.

For example, for the JavaBean package's chrysalis.xml configuration file, localization information can be put in localized variants of this file:

  • Base configuration: chrysalis.xml.
  • English configuration: chrysalis_en.xml.
  • US configuration: chrysalis_en_US.xml.
  • French language configuration: chrysalis_fr.xml.
  • Configuration for France: chrysalis_fr_FR.xml.

The configuration library first searches the country-specific configuration file, then the language-specific and finally the generic configuration file. Full details of the configuration search algorithm can be found in the documentation for the org.chwf.config package.

Converters

The Chrysalis converter library uses localized algorithms to convert datatypes to and from string values. It determines the correct locale using the UserLocale.getLocale() method. The default converters included in Chrysalis uses the internationalized classes in the java.text package to perform its conversions. Custom converters can follow a similar process.

Internationalization Tags

Chrysalis includes a library of internationalization tags in the ji18n tag library. These tags support such features as localizable messages in JSP pages.

In addition, the <jutil:print> tag can specify a logical datatype for each printed value to control how data values are printed in a page.