Sun ONE logo     Previous      Contents      Index      Next     
Sun ONE Web Services Platform Developer Edition Developer's Guide



Logistics Sample Application: Internationalization

The Logistics Sample Application is designed to accommodate issues related to internationalization (i18n) and localization (l10n) whereby it can be adapted to various languages and regions without code changes.

This section details the various aspects of Internationalization and how the Logistics Sample Application deals with them.

Getting the User Locale

For the Cargo Line administration module and the Customer Order Center, the locale is read from the browser, and is retrieved from HTTPRequest.

For the Insurance Client, which is a rich client (java application), the locale is retrieved from the operating system.

Displaying Locale Specific Pages on the Browser

The pages that are displayed to the user are per the locale.

The Logistics Sample Application takes care to assign separate areas for locale specific pages, and gets these based on the user's locale.

Two variables are read from the Locale:

  • LanguageCode
  • LanguageCode is the ISO 639 language code, two character code, (for example, FR for French).

  • CountryCode
  • CountryCode is an ISO 3166 country code (for example, IT for Italy).

The Cargo Line administration module supports this by having a locale specific directory under the JSP directory. Out of the box, there is the jsp/default directory, or the directory from where the JSP files are picked up if the locale specific directory is not found.

The locale directory is specified either by <LanguageCode> or <LanguageCode>_<CountryCode>. The FlowManager reads the locale, and first tries to get the JSP page from the directory <LanguageCode>_<CountryCode>. If this is not found, it looks for the page under <LanguageCode>. If this is also not located, it returns the page from the default directory.

To localize, create a new directory as either <LanguageCode>_<CountryCode> (for example, zh_CN) or simply <LanguageCode> (for example, zh), and copy the JSP files from the default directory, and localize the labels.

The Cargo Line Customer Order Center supports this by having a locale specific file. This approach is different from that of the Administration module.

The OrderCenterViewBean looks at the name of the JSP file it needs to display back (BaseJSPPage), and checks for the existence of BaseJSPPAge_<LanguageCode>_<CountryCode>.jsp. If this does exist, it displays that page, or looks for BaseJSPPAge_<LanguageCode>.jsp. If neither of the two files exists, it displays back the BaseJSPPAge.jsp.

To localize, create a new JSP file as either BaseJSPPAge_<LanguageCode>_<CountryCode>.jsp (for example, SearchShipment_zh_CN.jsp), or just BaseJSPPAge_<LanguageCode>.jsp (for example, SearchShipment_zh.jsp).

Of the two strategies, the one followed by the Cargo Line Administration module is recommended, as it provides a cleaner approach and is more manageable.

The Insurance Client is a rich client, and it reads its labels from a properties file.

Handling Error/Information Messages

The Logistics Sample Application uses ResourceBundle provided by J2SE to get localized messages. The messages are read from a corresponding properties file.

The properties file is located in the components/common/com/sun/developerplatform/logistics/cargoline/common directory. The resource name is CargolineBundle. This file is included as a part of common.jar, and is available to the Administration module, Order Center module, and Webservice module.

To localize, simply create a CargolineBundle_<LanguageCode>_<CountryCode>.properties or CargolineBundle_<LanguageCode>.properties file, jar up common.jar, and reploy the modules with the new JAR file.

Date Formatting, Number Formatting, and Currency Formatting

The Logistics Sample Application addresses date, number, and currency formatting by providing a convenience class called Localiser.java. This class is used throughout the Logistics Sample Application to display locale specific content. Internally it uses NumberFormat, DateFormat, Collator, and MessageFormat classes available as part of J2SE to display and get locale specific information.


Previous      Contents      Index      Next     
Copyright 2003 Sun Microsystems, Inc. All rights reserved.