Flash Internationalization Programming
Locale, Date, Time, and Currency

The followings are basic internationalization points of ActionScript.
  1. Locale Detection

    ActionAscript can detect a user language of the client where it runs by flash.system.Capabilities.language property.
    But you should note that this is not a complete locale name, just a language name only,
    and this property value is the original OS language and doesn't reflect any browser language settings.
    To reflect browser language settings, you need to write and call JavaScript for getting languages, or give them as parameters of Flash objects(FlashVars).

    The following sample is getting user locales by FlashVars.

    ====== HTML to load flash =====
    <html>
    <object width="100%" height="100%" >
    <!-- Edit locale to the suitable one. -->
    <param name="FlashVars" value="locale=ja_JP" />
    <!-- Edit locale to the suitable one. -->
    <embed  width="100%" height="100%" src="Main.swf" FlashVars="locale=ja_JP" />
    </object>
    </html>
    
    *If you use PHP or JavaScript, you can switch 'ja_JP' dynamically into user locales.
    
    ====== ActionScript =====
    public function Main():void
    {   
    var FlashVars:Object = this.root.loaderInfo.parameters; 
    var locale = FlashVars["locale"];
    
    *locale contains 'ja_JP'.
    
    
    About details of locale, refer to Here.


  2. Date, Time, and Currency

    You can process date, time, and currency on each locale using classes of flash.globalization package.
    These classes enable locale switching on OS language settings using flash.globalization.LocaleID.DEFAULT.
    (*Note that flash.system.Capabilities.language cannot be used.)

    The following is a sample of showing the current date in suitable format to OS language settings.

    var df:DateTimeFormatter = new DateTimeFormatter(LocaleID.DEFAULT, DateTimeStyle.SHORT, DateTimeStyle.NONE);
    var currentDate:Date = new Date();
    var shortDate:String = df.format(currentDate);
    
    *LocaleID.DEFAULT itself is "i-default".

    *mx.resources.ResourceManager used by Resource Handling doesn't support LocaleID.DEFAULT.

    The following sample is getting user locales by FlashVars.
    var FlashVars:Object = this.root.loaderInfo.parameters;
    var locale = FlashVars["locale"];
    var df:DateTimeFormatter = new DateTimeFormatter(locale, DateTimeStyle.SHORT, DateTimeStyle.NONE);
    
    About flash.globalization, refer to Here.


  3. Deprecated Methods and Classes

    ActionScript has many deprecated methods and classes in each version.
    You should note that some of deprecated ones act different than before or incorrectly.
    Especially, some of locale and resource related ones do act that.

    About deprecated methods and classes, refer to Here.


Go to Internationalization Programming Top


Copyright (C) 2012 Kokusaika JP, Inc.
All rights reserved. No reproduction or republication without written permission.