A locale identifies a specific combination of language and cultural
conventions for a country or region.
A locale identifier can be safely managed as a string. But you
can use the LocaleID class to obtain additional information related
to a locale.
You create a LocaleID object as follows:
var locale:LocaleID = new LocaleID("es-MX");
After the LocaleID object is created, you can retrieve data about
the locale ID. Use the
getKeysAndValues()
,
getLanguage()
,
getRegion()
,
getScript()
,
getVariant()
,
and
isRightToLeft()
methods, and the
name
property.
The values retrieved from these methods and properties can reflect
additional information that cannot be extracted directly from the
locale identifier about the locale.
When an application creates a locale-aware service, such as a
date formatter, it must specify the intended locale. The list of
supported locales varies from one operating system to another; hence,
the requested locale can be unavailable.
Flash Player first tries to match the language code of the locale
that you requested. Then it tries to refine the locale by finding
a matching writing system (script) and region. For example:
var loc:LocaleID = new LocaleID("es");
trace(loc.getLanguage()); // es
trace(loc.getScript()); // Latn
trace(loc.getRegion()); // ES
In this example, the
LocaleID()
constructor
retrieved data about the locale that best matches the language code
“es” for that user.
Limitations of other locale and language classes
The
fl.lang.Locale
class lets you replace
text strings based on a locale, using resource bundles containing
string values. However this class does not support other internationalization
features such as number, currency, or date formatting, sorting and
matching, and so on. In addition, this class is only available with
Flash Professional.
You can also retrieve the current language code setting for the
operating system using the
flash.system.Capabilities.language
property.
However, this property retrieves only the two-character ISO 639-1
language code—not the full locale ID—and it only supports a specific
set of locales.
With AIR 1.5, you can use the
flash.system.Capabilities.languages
property.
This property provides an array of the user’s preferred user interface languages.
Thus, it does not have the limitations of
Capabilities.language
.