Internationalization
The Java VM lets us write code that executes in the same way on any Java platform. But in a global marketplace, that is only half the battle. A big question remains: will the application content and data be understandable to end users worldwide? Must users know English to use your application? The answer is that Java provides thorough support for localizing the text of your application for most modern languages and dialects. In this section, we’ll talk about the concepts of internationalization (often abbreviated “I18N”) and the classes that support them.
The java.util.Locale Class
Internationalization programming revolves around the
Locale class. The class itself is
very simple; it encapsulates a country code, a language code, and a
rarely used variant code. Commonly used languages and countries are
defined as constants in the Locale
class. (Maybe it’s ironic that these names are all in English.) You can
retrieve the codes or readable names, as follows:
Localel=Locale.ITALIAN;System.out.println(l.getCountry());// ITSystem.out.println(l.getDisplayCountry());// ItalySystem.out.println(l.getLanguage());// itSystem.out.println(l.getDisplayLanguage());// Italian
The country codes comply with ISO 3166. You will find a complete list of country codes at the RIPE Network Coordination Centre. The language codes comply with ISO 639. A complete list of language codes is online at the US government website. There is no official set of variant codes; they are ...