Thursday, August 10, 2006

Flash 8 and multilingual support

Yesterday I was looking for options to create multilingual application in Flash 8.
I got a handy option to create this using Strings Panel.
Let me describe a-z....
HOW TO CREATE...
First of all we need to create XML language files. Flash 8 reads 2 types of format...*.xml and *.xlf [XML Language File]
First we need to create XLIFF [XML language interchnageable file format]
Here is an example....
[GERMAN]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN"
"http://www.oasis-open.org/committees/xliff/documents/xliff.dtd" >
<xliff version="1.0" xml:lang="fr">
<file datatype="plaintext" original="combotest.fla" source-language="EN">
<header></header>
<body>
<trans-unit id="001" resname="IDS_GREETINGS">
<source>Willkommen zu unserer Web site!</source>
</trans-unit>
<trans-unit id="002" resname="IDS_MAILING LIST">
<source>Wurdest du magst auf unserer Adressenkartei sein?</source>
</trans-unit>
<trans-unit id="003" resname="IDS_SEE YOU">
<source>bald bis!</source>
</trans-unit>
<trans-unit id="004" resname="IDS_INFO">
<source>Es gibt zwei Arten Gegenstände auf das Stadium (zeichnender Bereich). Einen Gegenstand vorwählen, gerechtes Klicken auf es. Wenn Notwendigkeit, mehrfache Gegenstände vorzuwählen, Maus auf das Stadium schleppen. Alle Gegenstände innerhalb des Bereichs werden vorgewählt. Wenn Gegenstand ein Firmenzeichen und seine internen Elemente vorzuwählen ist, einfach fortfahren, zum Firmenzeichensymbol an zu klicken.</source>
</trans-unit>
<trans-unit id="005" resname="IDS_LINE1">
<source>Linie 1</source>
</trans-unit>
<trans-unit id="005" resname="IDS_LINE2">
<source>Linie 2</source>
</trans-unit>
</body>
</file>
</xliff>

[ENGLISH]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN"
"http://www.oasis-open.org/committees/xliff/documents/xliff.dtd" >
<xliff version="1.0" xml:lang="en">
<file datatype="plaintext" original="combotest.fla" source-language="EN">
<header></header>
<body>
<trans-unit id="001" resname="IDS_GREETINGS">
<source>welcome to our web site!</source>
</trans-unit>
<trans-unit id="002" resname="IDS_MAILING LIST">
<source>Would you like to be on our mailing list?</source>
</trans-unit>
<trans-unit id="003" resname="IDS_SEE YOU">
<source>see you soon!</source>
</trans-unit>
<trans-unit id="004" resname="IDS_INFO">
<source>There are two types of objects onto the stage (drawing area).
To select an object, just click onto it.
If need to select multiple objects, drag mouse onto the stage. All objects within the area will be selected.
If object is a logo and to select its internal elements, just continue to click on to the logo symbol. </source>
</trans-unit>
<trans-unit id="005" resname="IDS_LINE1">
<source>Line 1</source>
</trans-unit>
<trans-unit id="005" resname="IDS_LINE2">
<source>Line 2</source>
</trans-unit>
</body>
</file>
</xliff>

Now come to flash. Open a document, add 3 dynamic textfield(name is not required).
Go to Window -> Other Panel -> Strings.
Click on setting tab and add desired languages.
(In case of other languages, click on custom language and provide a identifier name that u have given in respected xml or xlf file.)
Click the repalce string option to AUTOMATICALLY AT RUNTIME.
Click on import XML for each given language.
Now select a textfield and choose string identifier from the list, apply, and apply for reach language.
The same process will be repeated for every other textfields.
Close the Strings Panel and come to action panel of first frame....
Write the code...

import mx.lang.Locale;

//Here u can pass the language identifier...
Locale.loadLanguageXML("de");

Now publish the file. If everything is OK, language will be automatically changed.

Hope this will reduce burden of multilingual application.
If anybody have better idea regarding this, APPRECIABLE....im lookin :)

DEL

No comments: