Wednesday, August 30, 2006

Shared fonts library and unicode

I was working with a multilingual application where we had to support almost all major languages like russian, thai, french, chinese etc...

My application was working fine with shared fonts with English, german, spanish, latin and french but problem arose when I tried to use cyrillic. I mean UNICODE. After long hours of hair pulling, I got a solution and this was very similar to dembicki's solution.

Let me go through step-by-step.

Open a blank FLA in flash 8.

Create a dynamic textfield. Choose your desired font for the desired language. You can use charmap or any other application that could show all languages supported by the font.









Embed desired gylphs for desired languages.











Select the dynamic textfield and convert it to movie. Give it a name like 'fonts'. Export for runtime sharing and also export for first frame. In URL section provide relative URL of the font swf or exact URL of the font swf.

You have to create seperate movieclips for bold, italic and bold italic....if necessary.









Delete the 'fonts' movie from the stage (Not from the library).









Now create an empty movieclip called 'ForceShared'. Import for runtime sharing. Give URL for the font swf same as given into fonts movie. A question arise here why same URL for both movies? Since source is same here for both (Exported movie and the movie that import the exported font), both URL would be same.










Drag the 'ForceShared' movie onto stage. And publish the swf into fonts folder.

Here your font library is ready for 'Thai' and 'Cyrillic'.
To use it just load dynamically into your application FLA. Create a input textfield dynamically and apply the font. Set embedFont is true. If eveything is gone in right direction.....Your application must show the desired text.

Advantages:

1. Font will be in a single file.
2. Easy to create.
3. Easy to use.
4. A solid solution of UNICODE related problems.
5. The same procedure will be applied for prescribed

Disadvantges:

1. If you have embeded Normal font that you cant use Bold or Italic. You must have to embed others also otherwise these will not work. If embed, could raise filesize so be cautious about it. Better it to define supported format in your font xml file so that you could know which format is supported by the font library. Lets example if we are using Chinese, there are many fonts which support only normal/Italic or bold/italic.

At last I want to tell you as written in quasimondo.com that try to create seperate font library for each languages. Dont mesh all languages.

You can mail me or leave a comment for it. Thanx!

DEL

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