1.2. Language and country codes: Java Locale

Technically, when a user configures his language, a Java Locale is stored for this user. A locale consists of three parts: de_CH_ZH

  1. The language : e.g. German, only lower case letter

  2. Optional: the country : e.g. Switzerland, only capital letters

  3. Optional: the variant : e.g. Zürich (often used for a dialect) only capital letters

Since Java checks for valid languages it is mandatory to only use language and country codes that actually exist:

  1. Valid language codes

  2. Valid country codes

It is very common to use only the language part. Sometimes it is handy to add the country part. The variant is almost never used.

The idea behind this concept is that it is possible to build a system that implements a hierarchy of translations: common elements are defined in the languages, those that are country specific are defined on country level and finally messages that are even more specific use the variant part:

de: contains the translations that are valid in all German speaking countries

de_CH contains translations that differ from the basic German translation, i.e. spellings and expressions unique to Switzerland. So does de_DE contain specific translation for German users.