LocaleManager

The LocaleManager class manages system locale changes. It enables you to both listen for system locale changes and set the
locale of an application.

You can place a resource String file in the following folder in your application directory:

locale/<locale id>/resource.properties

where <locale id> is a valid locale ID, such as en_US. You can place any other localized assets in this folder, such as
images and fonts. The getLocalePath() function returns the path to the current locale directory.

A resource file has the following format:

key1=resource_string_1
key2=resource_string_2
key3=resource_string_3

where key1 is a resource key, and resource_string_1 is the translatable, locale-specific String. See the
LocaleResourceBundle class for more information about resource bundles.

Returns

getDateOrder()

The order of the date elements is dependent on the style used to format the date.
By default both date and time styles use DateTimeStyle.SHORT.
Valid values for each parameter can be found in flash.globalization.DateTimeStyle;

DateTimeStyle.NONE

DateTimeStyle.SHORT

DateTimeStyle.MEDIUM

DateTimeStyle.LONG

Parameters

dateStyle:String (default = NaN) — The date style to be used. The default is DateTimeStyle.SHORT.

timeStyle:String (default = NaN) — The time style to be used. The default is DateTimeStyle.SHORT.

Returns

Vector.<String> — A String Vector with values of LocalDateTime.DAY, LocalDateTime.MONTH, LocaleDateTime.YEAR, in the order which they should be displayed.

getDeviceLocale()

public function getDeviceLocale():String

Returns the current locale of the device.

Returns

String — The ID of the current locale.

getDeviceRegion()

public function getDeviceRegion():String

Returns the current region of the device.

Returns

String — The ID of the current region.

getLanguage()

public function getLanguage():String

Returns the two character language code of the locale. For example
the locale en_US would have a country code of en.

Returns

String — The language of the current locale.

getLocalePath()

public static function getLocalePath():String

Returns the path from the application directory to the current locale directory in the format, locale/{locale id}/.

You can place any localized asset in the application's locale directory. This path allows you to reference an asset
in the currently selected locale. In the example below, the getLocalePath() method is called to load
a locale-specific image in an IconButton instance:

setLocale()

public function setLocale(locale:String):void

Sets the locale of the application, given the locale ID.

This function dispatches a flash.events.Event.CHANGE event when the current locale resources have been loaded and parsed.
Until the resouces have been loaded and parsed, any queries to getResouce will return resources from the previous locale.

Event Detail

change

Dispatched when the locale has been changed and the associated localization resources have finished loading.

Constant Detail

LOCALE_FOLDER

public static const LOCALE_FOLDER:String = locale/

A String representing the location of the locale folder.

Examples

The following example uses the LocaleManager to load a set of locale-specific resource Strings. A list is instantiated and loaded with resource Strings and an event
listener is added to listen for locale changes. When a locale change occurs, or when the application loads, the onLocaleChange function is called
to load the resource strings for the current locale. You can add this same functionality to your application in order to globalize your Strings or images.