This is documentation of an archived release.
For documentation on the current version, please check Knowledge Base.

Flex Localisation

Some notes on making use of translations in Flex.

1. Compiler Settings

To localize your flex application, you must first tell the flex compiler which locales you want to embed in your target application. You can configure the locales you want to add in the Project Properties→Flex Compiler panel. You can see an example below.

Flex SDK Translations

Note that the locales you configure here, also need to be present in the Flex SDK. If they are not, Flex Builder will complain. As a quick fix, you can use the copylocale script, present in every SDK, to generate stub-translations by copying from another locale.

# in a terminal,
# go to the 'Adobe Flex Builder 3 Plug-in' directory and type:
cd sdks/3.0.0
bin/copylocale en_US tr_TR

For the final version of your application, you may want full translations of the Flex SDK. Translations for numerous languages are available from Adobe's opensource repository. Below is a link to a tutorial for retrieving these locales from the opensource repository.

http://nsdevaraj.wordpress.com/2009/06/24/using-creating-locale-for-your-language/

Another option is BabelFlex, which is a project that offers swc libraries holding the Flex SDK translations for different locales.

http://blog.baao.com/Tontons_Flexeurs/BabelFlex.html

2. Project requirements

After that you must add a folder with localisation resources for each locale. Add a 'locale' folder to your project, and add a sub-folder for each locale.

Now you are all set!

3. Setting the Locale Chain

To make use of translations, you must configure the locale chain. The locale chain defines the sequence in which the resource manager looks for translations. For example if the locale chain is [“en_US”,“fr_FR”] then the manager will first look for an english translation. If that is not found, it will look for a french translation. If that is also not found the system will return null.

Below is a small application setting the locale chain on startup. Note that in flex the localeChain can also be changed while the application is running, because most translation strings are dynamically bound to the resource manager.

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               creationComplete="handleCreationComplete()">
	<fx:Script>
		<![CDATA[
 
			private function handleCreationComplete():void
			{
 
				/* Set locale chain */
				resourceManager.localeChain = ["tr_TR","en_US"];
			}
 
		]]>
	</fx:Script>
</s:Application>
 
Last modified:: 2019/03/25 11:36