Using the LocaleID class

The LocaleID class, available in Flash Player 10.1, provides methods and properties for using locale IDs. Locale IDs are strings that represent a particular locale. They can be useful when deciding whether to change the layout direction of an application.

The LocaleID class includes the isRightToLeft() method, which returns true if the currently set locale uses an RTL character code set, but otherwise returns false. You can use this method to set the values of the layoutDirection and direction properties. When you change locales in the following example, the application checks the isRightToLeft() method and sets the layoutDirection and direction properties on the Application object accordingly:
<?xml version="1.0" encoding="utf-8"?>
<!-- mirroring\LocaleIDMirroringExample.mxml -->
<s:Application xmlns:fx="" 
            width="300" height="300"
            import flash.globalization.LocaleID;
            import mx.collections.ArrayCollection;          

            public var localeBasedDirection:String;

            public var locID:LocaleID;

            public var myDP:ArrayCollection = new ArrayCollection(
                [ {name:"US", locale:"en_US"},
                    {name:"Israel", locale:"he_IL"},
                    {name:"France", locale:"fr_FR"} ]);
            private function updateSelection():void {
                locID = new LocaleID(localeIdList.selectedItem.locale);                
                isRTLLabel.text = "RTL: " + locID.isRightToLeft().toString();
                getRegionLabel.text = "Region: " + locID.getRegion();
                getLanguageLabel.text = "Language: " + locID.getLanguage();
                if (locID.isRightToLeft()) {
                    localeBasedDirection = "rtl";
                } else {
                    localeBasedDirection = "ltr";

    <s:Panel title="Select Locale" height="200" width="250">
            <s:VerticalLayout paddingLeft="10" paddingRight="10" paddingTop="10"/>
            <s:DropDownList id="localeIdList" selectedIndex="0" 
            <s:Label id="isRTLLabel"/>
            <s:Label id="getRegionLabel"/>
            <s:Label id="getLanguageLabel"/>

The executing SWF file for the previous example is shown below:

This example requires classes in the flash.globalization.* package, which are available in the 10.1 or later playerglobal.swc file. When compiling this example, be sure to set the target player version to 10.1 or later. In Flash Builder, this option is on the Compiler properties page. On the command-line, you can set the target Player version by using the target-player option; for example:
mxmlc -target-player=10.1 MyApp.mxml
In your applications, you will typically have some additional logic that sets the locale in your application, such as looking at the OS language code or accepting a user-configured setting. For information on setting locales in your application, see Setting the locale. For more information about using the classes in the flash.globalization.* package, see Flash Player: Cultural diversity without complexity.