Java internationalization with the Properties Pre-Processor

An XML-based utility for handling localized strings

Properties files are used to store and maintain the localized strings at the heart of most internationalized Java applications. It's too bad maintaining several properties files can be such a headache. In this article Melih Çetin introduces the Properties Pre-Processor, an XML-based utility that enables UTF-8 encoding and lets you maintain localized strings for all of your supported locales in a single XML file, as well as easily sharing them across multiple applications.

Like any other commodity these days, a good percentage of Java applications are marketed and sold internationally. Java Web applications especially must be written with the global marketplace in mind, regardless of whether they originate from the United States, Germany or China. You cannot easily internationalize your software after it has been built (although some tools facilitate this process), or decide midway through the development process to add localization support to your Java applications. The earlier you start thinking about the steps involved in internationalizing your Java applications, the better.

In this article I will briefly introduce the common concerns associated with internationalizing Java applications, as well as the classes that support internationalization on the Java platform. I'll then introduce a simple tool that supports the internationalization of Java applications by making it easier to create and maintain localized strings for UI elements and add new ones as your application is extended for new languages.

Note that this article is not intended as a comprehensive introduction to internationalizing Java applications. See the Resources section for a listing of articles and tutorials about internationalization.

Qualities of an internationalized application

The Java platform provides considerable support for internationalization. When developing desktop applications you do not need to do anything special to identify the user's language preference: the JRE sets your application's locale based on the user's settings in the underlying operating system. Of course, it is possible to make the language settings for your desktop application configurable, and you certainly will need to address language preferences when developing internationalized applications for the Web.

Regardless of whether it will be distributed in desktop environments or on the Web, an internationalized Java application should do the following:

  • Display captions and messages in the user's language.
  • Use the correct collating sequence when sorting strings.
  • Display the date in the format expected by the user.
  • Display numbers such as integers, real numbers, percentages and currency in the format expected by the user.
  • Adjust the directional flow of text as expected by the user.

To do these things your application must be language aware. java.util.Locale is the utility class used to define language, or more specifically locale, in Java applications.

1 2 3 4 Page 1
Page 1 of 4