Previous | Next | Trail Map | Writing Global Programs | Internationalization? Localization? Arg!

Common Problems with Global Programs

The WordMatch applet, written by Pat Chan, guarantees you'll be a polyglot in minutes or your money back.

Since you can't run the applet, here's a picture of it:

This applet is, seemingly, an obvious candidate for internationalization. Let's investigate the problems we would encounter if we attempted to internationalize it.

While running the WordMatch applet and playing with it, several features jump out as candidates for localization:

  1. The words (lips, Java, television, dog, and so on).
  2. The corresponding sounds.
  3. The list of languages.
  4. The status messages that appear at the bottom of the window.
  5. The Score button title.
Many of these items present some programming problems. Indeed, these problems are the ones that most programmers will encounter when writing a global program, or transforming an existing program into a global program.

Problem One: Identifying the User

The first thing the program will have to do when invoked is to identify the user's locale. This provides the program with the information necessary to choose the language in which to display text, how to format data, how to layout text, what fonts to use, and so on.

Problem Two: Locale-Sensitive Data

All of the text in the applet that is visible to the user, including the list of languages, the list of words, the GUI labels and the status messages, represent a relatively large set of data that is language dependent. Ideally, this information should be isolated from the other parts of the program that are not language dependent. Doing this compartmentalizes the program and makes it easier to translate and maintain the program.

Additionally, non-text language-dependent data, such as the audio clips in the WordMatch applet, should also be treated in this way.

Problem Three: Data Formatting

As you play the WordMatch applet, various status messages appear beneath the playing area: The first two messages can be translated into different languages in a straightforward manner but the third message is more complex. In English, this message has 3 parts that are concatenated in this order: "There are", 2, and "correct matches". However, in other languages the number and order of the message parts may change, thereby complicating the code that generates the message. The message needs to be formatted in an internationally-sensitive way without comprising the language-independent nature of the rest of the program.

Displaying numbers poses a similar formatting problem. The number displayed in the "correct matches" message is a small integer number. Even this number may have a different representation in different languages. Certainly, larger numbers, decimal numbers, currency numbers, or percentages, must be formatted differently for different areas of the world.

Dates and times are another category of data type that requires internationally-sensitive formatting.

All of these, messages, numbers, and dates, should be formatted in a style consistent with the user's locale and in a way that doesn't compromise the language-independence of the actual program.

Problem Four: Sortable Lists

The list of language names on the left side of the applet should be translated into the currently selected language--the names should be in Japanese when Japanese is selected and so on. When a list such as the language list is translated from language to language, the items in the list become unsorted from one language to the next and need to be re-sorted according to the rules of the new language. Building this type of functionality into your program requires expertise in every language in the list and lots of programming time and maintenance.

Problem Five: Non-Roman Alphabets

Several languages in the language list use a non-Roman alphabet, Japanese, Mandarin, and Hindi for example. When one of these languages is selected, all text should appear in those alphabets.
The next page of this lesson shows you how the JDK 1.1 solves these and other problems that you may encounter when writing a global Java program.

For the transformation of the WordMatch applet into a global program, see the Internationalizing an Existing Program: Step by Step lesson.

Previous | Next | Trail Map | Writing Global Programs | Internationalization? Localization? Arg!