Locale (Runtime - JavaScript)
A Locale object represents a specific geographical, political, or cultural region. An operation that requires a Locale to perform its task is called locale-sensitive and uses the Locale to tailor information for the user. For example, displaying a number is a locale-sensitive operation because the number should be formatted according to the conventions of the user's native country, region, or culture.
new Locale(language:string)
new Locale(language:string, country:string)
new Locale(language:string, country:string, variant:string)
The second parameter is a valid ISO Country Code. These codes are the upper-case two-letter codes defined by ISO-3166.
The third parameter
is the Variant code. The Variant codes are vendor and browser specific.
For example, use WIN for Windows™,
MAC for Macintosh, and POSIX for POSIX. Where there are two variants,
separate them with an underscore, and put the most important one first.
For example, a Traditional Spanish collation might construct a locale
with parameters for language, country and variant as: new
Locale("es", "ES", "Traditional_WIN")
.
The Locale
class provides a number of convenient constants that you can use to
create Locale objects for commonly used locales. For example, the
following creates a Locale object for the United States: Locale.US
.
Once you create a Locale you can query it for information about itself. Use getCountry to get the ISO Country Code and getLanguage to get the ISO Language Code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user. Similarly, you can use getDisplayLanguage to get the name of the language suitable for displaying to the user. The getDisplay methods are themselves locale-sensitive and have two versions: one that uses the default locale and one that uses the locale specified as a parameter.