The Script Locale |
Active Web |
A locale identifies a language and a country. This identity is then used for internationalization. For example to display the correct language or format a date string correctly.
When a script page is run it has a locale that is based on the language and country sent in the HTTP request. If the request has come from a browser then this locale will be the language configured in the users browser. This will have been set to a known default when the operating system was installed but the user can change it. If the language and country are not specified (the HTTP protocol does not insist upon them) then the script will be given the default locale for the script server and this will depend on the operating system of the server.
The script locale is used for following:
The loading of InternationalFragments.
The loading of InternationalTokens.
The formatting of InternationalTokens.
The formatting of Date strings.
A locale is hierarchical in that if an exact match for language and country fails then it will match just the language and if that fails it will match the null locale. This feature can be used in InternationalFragments and InternationalTokens to reduce the number of locales that need to be catered for and to have a default (null locale) operation.
Locales are often identified by a locale string.
A locale string consists of a language, a country and a variant (hardly ever used). The string has two characters for language, two for country and any number for the variant each part separated by an underscore. A locale string does not have to have a variant or a country. If the string has a country then it must have language and it has a variant then it must have a country.
Here are some examples of valid locale strings:
en
en_us
fr
fr_ca
fr_ca_quebec
A list of all language codes can be found at http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt, and a list of all country codes can be found at http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html. There is no list of variants.
Topic ID: 150106