The Source for Java Technology Collaboration


Home | Help | Changes | Index | Search | Go

Internationalization / Localization

Java supports internationalized applications which can be localized to different languages (and sometimes countries, cultures, etc.).

Localization in short means two things:

  1. Translate the text on screen to the locate of the user. Internationalization (i18n)
  2. Show automatically formatted text using the formats of that user. Localization (l10n)

Internationalization

Internationalization is about the language the application is using to talk to the user. The art of translating text on screen in java is still not mastered into a good specification, this is probably because it appears easier then it actually is. For an application to be translated correctly each text string on screen has to be translated while showing the application, this in contrast to altering the source code. There are a number of challenges that have to be taken in order to get a correctly translated application:

  1. Normal labels have to be translated.
  2. Combobox and list entries need to be translated on view, but not the actual data that is displayed. If your combobox shows a list of cities then those cities will have different names when the application is shown in a different language. The selected city should, for saving, not change.
    So we need a separation of content and translated text.
  3. Combined text needs a smarter translation. It is not always possible to translate a string like 14 of 40 bytes into 2 parts and concatenating the parts with the numbers. There are languages that want that order to be reversed; so the translation would have to be done as one string.
  4. Since translated text can be bigger or smaller then your original (untranslated) text your GUI would have to be using a Layout Manager to scale all widgets to fit.
  5. non latin languages have many differences to latin languages. The most obvious one is that the string a quarter to two and the string a quarter past two have the following text in common: a quarter. Unfortunately in slavic languages that text is different depending on which side of the hour you are. Concatenating translated text does not work, and a 'lookup table' is not a solution for those languages.
  6. For button-shortcuts and other widgets you can provide mnemonics?. It is needed to provide different mnemonics per language since the technique relies on the mnemonic character to be present in the word.

Internationalization of applications obviously require the application provider to provide the correct translations at run time, this is done in Java using [[Resource bundles] to allow a pre-defined file format and naming convention to be used. The immediately obvious advantage is that one application can ship with many of these resource bundles and the user can choose which language to use when starting the application.

Localization

Independent of language the user can choose the localization options. If the internationalization is about the language in which an application is shown, then localization is about the country in which the user is using the application. Providing date formats is the most obvious example of localization. Java already provides other obvious information like what the first day of the week is.

i18n and l10n combined

In theory the user should be free to choose any language that she wants after choosing the country of choice. The design in Java, however, is limiting this to only valid selections in official languages spoken in official countries. Java fails to understand you if you choose English as your preferred language, and you are in Spain.

What does Java do for you

In Java there are lots of l10n string and formats pre defined; many Swing widgets, as well as classes like Calendar can provide localized data when you provide the correct Locale object in the method-call.

Translation of text is not very finished in the JRE, the basics of opening a file of translations and accessing that like a hashtable is provided, and there the support stops. There are various implementations that use that basic framework to provide user friendly (or should we call that developer friendly) interfaces for this.

Open source projects

Further readings


Written by Thomas Zander

Topic Internationalization . { Edit | Ref-By | Printable | Diffs r13 < r12 < r11 < r10 < r9 | More }
 XML java.net RSS

Revision r13 - 31 Jul 2007 - 11:39:08 - Main.scolebourne