Internationalization/localization in Flash applications
Weve just released a set of classes to help in the localization of internationalized Flash applications.
Although FlashMX2004 added several new features that greatly enhance the work flow for authoring multiple language Unicode-based applications there was a piece missing, there was no simple way to localize dates or number.
XPInternational makes it easy to:
Format and parse dates in a simple and standard way for any languages or locale.
Format and parse numbers in a simple and standard way for any different language or locale.
Create new locales.
XPInternational comes bundled with an assortment of Locale's more are available on demand.
If you ae interested to learn more then try here http://www.epresenterplus.com/i18n.shtml.
The pack is priced at only USD5.00 and as ever we welcome all comments, questions, discussions even if you are not interested in purchasing.
Sample Code
import xp.util.Locale;
import xp.util.Locale_zh;
import xp.util.Locale_fr;
import xp.util.Locale_enGB;
import xp.util.DateFormat;
import xp.util.NumberFormat;
Locale.addLocale(new Locale_fr());
Locale.addLocale(new Locale_zh());
Locale.addLocale(new Locale_enGB());
First we add the locale classes we want in this application. This only needs to be done once per application.
var d = new Date();
var dfEn= DateFormat.getDateInstance(DateFormat.MEDIUM);
var dfFr= DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getInstance("fr"))
var dfZh= DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getInstance("zh"))
var dfEnGB= DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.getInstance("en_GB"))
fr.text=dfFr.format(d);
zh.text=dfZh.format(d);
en.text=dfEn.format(d);
enGB.text=dfEnGB.format(d);
Next we obtain DateFormat objects, the first format objects doesnt specify a locale so it will use the current default locale.
Without recoding our application dates have been formatted in a locale specific manner.
var nfEn= NumberFormat.getCurrencyInstance();
var nfFr= NumberFormat.getCurrencyInstance(Locale.getInstance("fr"))
var nfZh= NumberFormat.getCurrencyInstance(Locale.getInstance("zh"))
var nfEnGB= NumberFormat.getCurrencyInstance(Locale.getInstance("en_GB"))
var n=19456.789
frNum.text=nfFr.format(n);
zhNum.text=nfZh.format(n);
enNum.text=nfEn.format(n);
enGBNum.text=nfEnGB.format(n);
Then we do the same for NumberFormat.
In this case we want to use a CurrenyFormat and once again for the first one as we dont specify a locale it will use the current default locale.
The currency format will automatically display the localized currency symbol and place it in the correct position all without our having to recode our application.
Regards
Rob
Comments
i am doing information about localization
Posted by: mian zain | July 29, 2006 11:14 PM