|
Adobe Flash Actionscript Flex Examples
|
|
|
|
|
|
Adobe Flex 3 Basic Locales Dynamic Runtime Localization With Resource Modules
JavaScript and the latest version of the Adobe Flash Player are required. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.
This is an example of localization to handle multiple languages for Flex 3 where the locale data is dynamically loaded at runtime. This example is for US English and French.
To use this you need to set the project Flex Compiler arguments to include the following: -locale= -source-path=../locale/{locale} -resource-bundle-list=bundles.txt You select the project properties and select Flex Compiler to do this. You also have to configure the Flex sdk for each language you want to use. So you need to go to the operating system command line and change to the sdk folder for the version of Flex Builder you are using. Then you run the Flex bin program copylocale.exe. In my case the operating system is Windows and this is the folder: C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0 You need to run the bin\copylocale.exe utility program from the command line and pass arguments to copy the one language locale folder Flex has. Here is what I did to include French bin\copylocale.exe en_US fr_FR It is tedious so I created a bat file for this task. It is in the download zip file and named MakeFrenchLocal.bat so you do not have to do command line steps. Place this in the sdk folder above the bin folder as shown above and just click on it. Duplicate for each language and then open to edit to change the language tags such as en_US fr_FR change to en_US fr_DE for German. These are one time commands. Each runtime language file is a separate swf from the Flex swf. So you have to convert the text language files to swfs. This step requires running the Flex command line mxmlc program. Change the name of the language file in both places in the command line such as en_US en_FR. Here it is and it needs to be repeated for each language: "C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\bin\mxmlc" "-locale=en_US" "-source-path=locale/{locale}" "-include-resource-bundles=collections,containers,controls,core,effects,myResources,skins,styles" "-output=src/Resources_en_US.swf" These steps need to be done each time you make a change to the text language classes. I created Windows batch files to simplify this process. The two I used for this example are included in the download: MakeResourceBundle_enUS.bat and MakeResourceBundle_frFR.bat. Place them in the Flex project above the src folder. Then duplicate for each new language and the edit to change the language tag in two places. Then you can open in Windows and click. Visit Adobe Labs article by Gordon Smith September 25, 2007 for the details why these additional steps are needed and the overall concepts. Note his example has a timing issue bug and I corrected that with this example. You can right mouse click over the example above to explore the source files.
All files for project src folder: Download
|
|
|
|
|
|
|
|