April 2012
« Mar   May »


<!–:ja–>Flash国際化プログラミング – リソース管理<!–:–><!–:en–>Flash Internationalization Programming – Resource Handling<!–:–>

The following are extracts from Flash Internationalization of Software Internationalization Tool World Wide Navi‘s Internationalization Programming Advisory Info.

Flash has two main resource handling styles, propeties files with mx.resources.ResourceManager and XLIFF with fl.lang.Locale.

Moreover, MXML can make labels directly into resources using ResourceManager.

For more details of each styles, refer to the following Adobe guides.



*XLIFF loading of fl.lang.Locale is desynchronized, so all string loading need to be in the call-back function.

This spec is not suitable for string switching during process, so wwnavi uses ResourceManager handling for string externalization.

*Many classes and methods related to ResourceManager are now deprecated. The following code In the end, those who really wanted to go to the enormous effort of analyzing this best-data-recovery.com were forced to work with snapshots of data. is no longer supported.

var r:SystemManager = new SystemManager(); var t:Locale = (r.topLevelSystemManager) ? Locale.getCurrent(r.topLevelSystemManager) : Locale.getCurrent(r);

Example: The sample code of resource switching by wwnavi.

These are process of getting the user locale from the Flash loading HTML to show resources suitable for users.

====== WwnaviRs.as (Resource loading class) ====== //$NLS-WWNAVI 2011-06-13T20:24:27 0900 package { import flash.system.Capabilities; import flash.external.ExternalInterface; import mx.resources.ResourceManager; /** * This class is automatically generated by wwnavi. */ [ResourceBundle("wwnaviRs")] public class WwnaviRs { private static var isInit:Boolean = false; private static var loc:String = null; public static function init():void { // Get user system language code  (without country codes in http://informesustentable.cl/viagara  most cases). loc = Capabilities.language; loc cialis brand 20 mg  = loc.replace("-", "_"); var cn:String = ""; // For using this code, the additional compile option, // "-locale=YOUR_LOCALE(e.g. en_US) -source-path=YOUR_RESOURCE_PATH(e.g. locale)/{locale}" is required. // If you add other locales, you have to add them to the option above. switch (loc) { case "en": cn = "US"; break; online drugs without prescription peaceap.org  case "ja": cn = "JP"; break; case "ko": over the counter metformin  cn = "KR"; break; case "zh": // do nothing. (loc has "_CN or _TW") break; // add your locale country codes. //case... // break; default: } if (loc.indexOf("_") == -1) { loc = loc "_" cn; } // Or get user browser language by your external JavaScript. // loc = getBrowserLang(); // In some cases, this code doesn"t work. ResourceManager.getInstance() .localeChain = [loc]; isInit = true; } // Get user locales from the HTML parameter. public static function initByFlashVars(flashVars:Object):void { loc = flashVars["locale"]; isInit = true; } public static function getString(id:String):String { if (!isInit) init(); // viagra online without prescription ResourceManager.getInstance() .localeChain = [loc] // levitra professional cheapest  doesn"t affect in some cases, so we added the following code. var str:String = ResourceManager .getInstance().getString("wwnaviRs", id, null, loc); if (str == null) buying viagra express  str = ResourceManager .getInstance().getString("wwnaviRs", id); return str; } /*public function getBrowserLang():String { var s:String; if (ExternalInterface.available) { var wrapperFunction:String = "YOUR_JAVASCRIPT_FUNCTION"; s = ExternalInterface.call(wrapperFunction); } else { s = "Wrapper not available"; } return s; }*/ } } ====== test.html (loading 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> ====== Main.as (Getting locales from HTML) ====== Write the process in entry points (e.g. Main). public function Main():void { WwnaviRs.initByFlashVars( this.root.loaderInfo.parameters); ====== Main.as (String loading function) ====== ... tx1.text =  WwnaviRs.getString("Main.1"); // tx1.text = "This is text 1."; ... ====== Resource File Location ====== ../locale/en_US/wwnaviRs.properties ja_JP/wwnaviRs.properties ... ../src/Main.as WwnaviRs.as ====== Resource File Contents ====== Main.3=This is text 3. Main.2=This is text 2. Main.1=This is text 1. ... Main.3=これはテキスト3です。 Main.2=これはテキスト2です。 Main.1=これはテキスト1です。 ====== Compiler Options ====== -locale=en_US,ja_JP -source-path=locale/{locale}

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>