5.4. Globalization Service

A globalized application is one that tries to equally accommodate readers of different languages and dialects. Elements of the application's user interface are shown in the user's preferred language, if it is supported. For example, a link to the categories page is displayed as Categories for English speakers and Kategorien for German speakers.

A partial list of globalization and localization facilities supported by the Java language includes:

The WAF globalization service provides classes and methods that can be roughly divided into the following three categories.

  1. Convenient wrappers around most-frequently used Java globalization APIs, such as resource bundles.

  2. Means of configuring the list of supported languages, locales, and character sets.

  3. A mechanism for locale and character set negotiation.

    Most modern browsers allow users to select their preferred language or a ranked sequence of preferred languages. The globalization service looks at the user's preferred language and locale, as reported by the user's browser, and compares them to the list of languages and locales that the system is configured to support.

    For example, a user can configure the preferred first language to be German ("de") and the preferred second language to be British English ("en_GB"). If the system is configured to support both of the languages, then the globalization service will choose "de" as the preferred locale. If the system has been configured to support British English, but not German, then the globalization service will choose "en_GB" as the preferred locale. If the system does not support either of the configured languages, then the service falls back to a default locale which could be "en_US" (US English).

    Once the desired locale is configured, a supported character set must be selected. For example, pages in German can be displayed using the ISO-8859-1 [1], UTF-8, or UTF-16 character sets. The user may express a preference by configuring their browser. The user's preference must then be reconciled with the list of character sets that the system has been configured to support.

This example of locale and character set negotiation is simplified for this discussion, but it illustrates the fact that correct negotiation is non-trivial. The globalization service relieves the developer of the burden of negotiating the preferred locale and character set correctly.

The WAF globalization service provides a set of high-level APIs based on the standard Java globalization facilities that handle issues such as language negotiation and localization of static strings. These APIs complement the basic globalization infrastructure provided by Java (i.e., ResourceBundles and property files are still used in WAF) and are specifically designed for use by web applications built with WAF.

Notes

[1]

http://www.htmlhelp.com/reference/charset/