Flash Localization Example

Tagged:  

Localization, Internationalization, or I18N, whatever you want to call it, is just a way to separate your text from your interface so that it can be translated and/or maintained apart from your application.

There are many benefits to this, even if you never plan on having your application in multiple languages. Localization makes your program more maintainable, easier to update, and more flexible to change.

Here's how to localize your content in Flash. It's a lot easier than you might think!

First, open your strings panel:

Then, configure the settings:

Create a text field, give it an instance name, and apply an ID to it. It must be a Dynamic text field.

That's enough to get you started. The xml created will be in the same directory your swf is published to, placed within language folders.

For further reference to localization, go to:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/lang/Locale.html

good post this help me match to start here working example

g_w_master@yahoo.com
ICQ:102716660
Good lack

// for crate text press CTRL+F11 and set settings
// setting sets once then you can change xml
// that's created at same directory as fla
import fl.lang.Locale;
Locale.autoReplace = true;
// create pointer object to text
var IDS_HELLO:Object = noMovieClip.hello;
var IDS_TEST_TEXT:Object = test_text;
// use once on load xml finish
//Locale.addDelayedInstance(IDS_HELLO, "IDS_HELLO");
//Locale.addDelayedInstance(IDS_TEST_TEXT, "IDS_TEST_TEXT");
// subscribe to load xml finish
Locale.setLoadCallback(updateText);
function updateText(success:Boolean):void {
var arr = Locale.stringIDArray;
for (var i = 0; i < arr.length; i++) {
this[arr[i]].text = Locale.loadString(arr[i]);
}
}
// load lang en,he,ru
Locale.loadLanguageXML("en");

// buttons
function en_select(event:Event) {
Locale.loadLanguageXML("en");
}
function he_select(event:Event) {
Locale.loadLanguageXML("he");
}

function ru_select(event:Event) {
Locale.loadLanguageXML("ru");
}
he_bt.addEventListener("click",he_select);
en_bt.addEventListener("click",en_select);
ru_bt.addEventListener("click",ru_select);

Hello Nick, could you point me to how to make it readable: I have an XML file with references to images loaded at runtime and as an attribute there asome chunks of text. It shows and swaps in English perfectly. But as soon as I include description into an xml file itself it stop show everything.
Thanks,
Andy

Hey Nick,

Are you going to write an article about Flex localization? If not, maybe I will, just to keep things balanced. I'm having fun viewing our blogs as yin and yang. :)

Now I have one up at /flex-localization-example