Each resource bundle has a different locale. The locale indicates the specific human language of the strings in the resource bundle. The locale is indicated by the end of the file name, before the .properties extension.
Locales consist of one to three identifiers. Each additional identifier after the first identifier enables you to indicate a more specific language by specifying the dialect, variety, or geographic location of the language. The identifiers are separated with an underscore character.
The simplest locales indicate a human language with a single identifier. This identifier is the language code of the language that is used in the resource bundle. For example, the language code en indicates English, and es indicates Spanish. An English resource bundle might be named resourceBundle_en.properties. The language code is part of the Java™ specification.
A more complex locale includes a language code followed by a country code. The country code indicates a country where the dialect of the language is spoken. For example, the country code US indicates the United States, and GB indicates Great Britain. In this way, an American English resource bundle might be named resourceBundle_en_US.properties, while a British English resource bundle might be named resourceBundle_en_GB.properties. The country code is part of the Java specification.
The most complex locale includes a language code, followed by a country code, followed by a variant code. The variant code defines a more specific dialect or variety of the language in the resource bundle. For example, you could use the variant codes A and B to distinguish between two different varieties of Norwegian spoken in Norway. These two resource bundles might be named resourceBundle_no_NO_A.properties and resourceBundle_no_NO_B.properties. Alternately, you could define a standard type of Norwegian as the locale no_NO and define a variant as no_NO_B. The variant code is not part of the Java specification.
If the user requests a locale that exactly matches a locale in the application, the resource bundle that represents that locale is the source of the strings that are used in the application. If the user requests a locale that is more specific than any of the locales in the application, the application uses a resource bundle with a more general locale. For example, if the user requests the locale no_NO_B, but the only available Norwegian locale is no_NO, the locale no_NO is used.
It is good programming practice to include a default resource bundle. The default resource bundle is used if the user requests no locale or a locale that is more general than any supported by the application. The default resource bundle has no locale. If no default resource bundle is specified, or if no locale can be loaded for the Web page, the page uses the string values that are specified on the page at definition time.