This content has been marked as final. Show 4 replies
When you use the Strings panel, the Locale class is used automatically to detect your operating system language and you don't have to worry. The question is, what if you want to control the language yourself using AS.
Here I send you an example. The conditions are:
Use the strings panel to create the texts in all the languages you have.
In the settings dialogs, set "via ActionScript at runtime" option on the Replace strings group.
This lets you control language via AS.
Then place the corresponding code to control languages. Because the languages are not loaded automatically you need to do it manually with some AS code. The following examples does the following.
It adds two xml files one for the english lang and one for the spanish lang. This files were automatically created with the strings panel so you have to see wich folder and what name your own created files are.
Then sets a function to run once the data is read.
Then it loads the corresponding language.
Finally creates the function that will run once the data is loaded.
You can call the different languages from different buttons too.
I used your code, but nothing happened. It seems that XML files weren't even loaded. Can you, please, check simple not-working-example I made and fix it? I'm really really confused by the whole locale concept and could not find any sufficient tutorial or anything about it ... it looks like noone uses it. Is it practical, or it's better to create your own mechanisms to load multilanguage content?
thanks a lot
zip file is here: FLA and XML files
might i get that customized locale class too .. i'm having problems with assigning two buttons to change language.
Problems are: Either the spanish language file when loaded gives me wrong characters and when i switch languages only english language appears correctly.
My email is oem [at] netcabo [dot] pt
Yep sorry my fault, look at the example I gave you again I have corrected it in a single line