Andrew Rayne: Internationalised Applications

« Scribble Board | Main | CairngormStore for Flex 2 »

August 18, 2006

Internationalised Applications

Hi, today I would like to talk about one method of Internationalising applications. On a recent project that I have worked on the client required that the application support multiple languages. In addition to this that the user should have the ability to switch languages at runtime and it should be reflected right throughout the application, in everything from labels to tooltips. Finally they wanted the application to allow for flexible addition of language support moving forwards.


Working in Europe I can imagine that this is going to be a common type of requirement in the future. Therefore I thought it might be worth sharing the approach taken in implementing this.

The built in localisation support in Flex didn’t quite give us what we were looking for in this instance. With the built in support you can read resource strings into the application from resource bundles at compile time. This allows you to compile a separate SWF for each language you wish to support.

The reason that wasn’t useful for this project is that in order to have changed the language with this approach the user would have had to load another SWF and this would not have been the seamless experience that we were aiming for.

In order to create what we wanted, we load the languages all at start up. This gives the client the data that it requires in order to quickly change the languages. An alternative here would be only to load the list of language names and a default language bundle at application start up. This would minimise on the amount of data we were loading on start up. The reason I chose not to do this here was that the amount of data being brought over the wire was not enough to cause a performance problem. Therefore going by the agile adage, this was “The simplest thing that could possibly work”.

The implementation of this is achieved by calling a server-side service. The example app is built on Cairngorm. I guess you could argue that with an app of this size I don’t really need Cairngorm as it’s too much overhead. That is true, however this isn’t meant to be production strength and I’m so used to using Cairngorm for larger apps that it seemed appropriate to show how the multi language functionality would fit in.

So, on start-up we dispatch a GetLanguagesEvent. This calls the GetLanguagesCommand which goes through the delegate to the service and eventually calls the server side LanguageService. The Service returns an ArrayCollection of languageBundles. These are set on the ModelLocator from the Command. At this stage we also set the locale on the LanguageHelper but more about that in a minute.

In the view component of the application, in this case the MultiLanguageSupport.mxml, we declare a LanguageHelper in the mxml and bind the languageBundles in the model to it.

In the LanguageHelper the languages being set causes a dictionary object to be created this holds the languageBundle objects and keys them on the locale code. Setting the languages will cause the languageChange event to be dispatched which will in turn cause all the bindings to the getString method to fire.

In order to change the language now all you have to do is set the locale on the LanguageHelper and it will change the current language and dispatch the languageChange event which will cause the bindings to getString to fire.

This approach has the benefit of being fully extensible. As long as you ensure that the server side language bundles are populated and your client-side label or tooltip binds to the getString method with the right key, you should be able to add further languages without changing any of the client-side code. Although it was done here you shouldn’t store the server-side resources in the code. These could easily be fetched from configuration files or a database allowing you to content manage your apps multilingual support easily.

In following posts I will share how we went about internationalising the numbers and dates in the application.

The code for the application can be found here.

Posted by arayne at August 18, 2006 06:25 AM

Comments

Great post, Thanks very much

Posted by: Dreamer at August 18, 2006 06:05 PM

Really clever idea.

Thanks for sharing your code with community.

Posted by: Igor at August 19, 2006 05:53 PM

Nice approach.

We sticked with the framework's ResourceBundle approach and successfully removed the need of statically linking the ResourceBundles into the SWF file by loading them dynamically and the initializing them after they're downloaded to the client.

This way we can also load localized versions of the complete Flex 2 framework into the hosting Flex 2 application while still using the .properties files approach.

Dirk.

Posted by: Dirk Eismann at August 20, 2006 11:27 PM

I went the other way. I have all language data on database, where it is well categorized. I created a smaal Java app that creates a language actionscript classes from that language db. Also the language can be selected by user dynamically, which causes the app to load the actual language from db and init the language classes with proper texts.

The major plusses with this approach is the fact that FlexBuilder 2 can now provide code hinting for the language files (since they are classes) and compiler will catch any references to non existing language texts (since they are attributes of an actionscript class). And also I have my language texts on database, where it can be easily edited and searched.

Previously with Flex 1.5 I actually used the method provided here, loading a language list and then dynamically loading a language to a model.

Posted by: Mika at September 12, 2006 12:54 AM

Dirk,
How did you remove the need to statically link the resource bundles into the swc file

Posted by: Brent Fournet at October 5, 2006 06:01 PM

Great solution...
So, and about the numbers and dates ?
We have a solution in runtime?

Posted by: Fredlee at November 28, 2006 04:43 AM

Excelent Article...
I have modified your example to use i18n in java (ResourceBundles in based on some Locales available in the server side...)

In this way, java's "i18n property files" can be shared between Flex and some jsp files that my app needs...
(and easier than database storage for i18n :P )

Posted by: Juan Carlos at January 14, 2007 06:22 AM

thanks so much.

Posted by: muhabbet at February 10, 2007 02:54 PM

thanks nice post

Posted by: sohbet at February 10, 2007 03:02 PM

Nice solution, great file.

Posted by: islami site islami sohbet at February 11, 2007 10:51 AM

l think very nice article

Posted by: resimler at April 23, 2007 11:24 AM

l think very nice article

Posted by: arabalar at April 23, 2007 11:25 AM

everybody very very thanks

Posted by: link at April 23, 2007 01:11 PM

ok

Posted by: Almousjbuiui at May 11, 2007 06:00 AM

Hi,
I guess I was late to find this article, could've helped me much before. Thanks anyway!

Posted by: zonenoktaorg at May 11, 2007 04:18 PM

thanks, very good article

Posted by: zonenoktaorg at May 28, 2007 12:21 PM

Hi,
Thank You ;)

Posted by: sohbet at May 28, 2007 12:49 PM

thank you Dirk Eismann

Posted by: sarki sozu at May 28, 2007 12:50 PM

Thank you admin

Posted by: sohbet at May 28, 2007 12:50 PM

thank you Dirk ok

Posted by: resimler at May 28, 2007 12:51 PM

Thank weblogs ..

Posted by: chat at May 28, 2007 12:51 PM

web logs thank

Posted by: avrasya at May 28, 2007 12:52 PM

Good article..

Posted by: canlı tv at May 30, 2007 08:29 AM

Andy,
thanks once again. Finally managed to install it.

Posted by: seoyarismasi at May 30, 2007 09:50 AM

thank you

Posted by: estetik at June 5, 2007 10:29 AM

Thanks for this article

Posted by: arabalar at June 21, 2007 05:10 AM

thanks..

Posted by: resimler at June 21, 2007 05:10 AM

Thnk you Andy

Posted by: bebek resimleri at June 21, 2007 05:11 AM

Thanks andy. it is perfect.

Posted by: resim yükle at June 21, 2007 05:12 AM

Thanks Andy..

Posted by: rüya at June 21, 2007 05:13 AM

Thanks tihs article help me high..

Posted by: gazete oku at June 21, 2007 05:14 AM

Thanks..

Posted by: arabalar at June 21, 2007 05:14 AM

Thanks andy

Posted by: gazete at June 21, 2007 05:16 AM

thanks Andy it is so help me .

Posted by: güzel resimler at June 21, 2007 05:17 AM

Veryy Goodd sıte Thank You..

Posted by: chat at June 24, 2007 01:21 PM

Thank Youu

Posted by: Sohbet at June 24, 2007 01:24 PM

thanks all

Posted by: sohbet at June 26, 2007 03:10 PM

thanks

Posted by: youtube at June 28, 2007 06:59 AM

good thanks desing

Posted by: program at June 28, 2007 06:59 AM

thanks macromedia

Posted by: indir at June 28, 2007 07:00 AM

thanks for

Posted by: download at June 28, 2007 07:01 AM

Thanks..

Posted by: araba at July 1, 2007 02:20 AM

very good.

Posted by: sohbet at July 3, 2007 12:53 AM

hi.

Posted by: video at July 3, 2007 12:53 AM

dsd.

Posted by: dini sohbet at July 3, 2007 12:54 AM

very good

thanks

Posted by: 月饼 at July 3, 2007 10:01 AM

very good.

Posted by: 哈根达斯 at July 5, 2007 03:14 AM

thanks

Posted by: resimler at July 5, 2007 07:15 AM

Thanks Andy..

Posted by: resimler at July 5, 2007 07:19 AM

thanks

Posted by: bebek resimleri at July 5, 2007 07:22 AM

thanks macromedia and andy

Posted by: Media at July 5, 2007 07:23 AM

thanks

Posted by: sohbet at July 5, 2007 07:25 AM

thanks andy

Posted by: oyunlar at July 5, 2007 07:26 AM

thanks good

Posted by: kapı at July 6, 2007 03:39 PM

Thanks for help... I will apply this really soon !

Posted by: niko at July 10, 2007 01:18 AM

You are correct this is going to be a common type of requirement in the future I think too.
Good works

Posted by: Resimleri at July 10, 2007 02:48 PM

very Good site...

Posted by: Sohbet at July 12, 2007 10:44 AM

Thanks

Posted by: Şiir at July 12, 2007 10:45 AM

very Good.!

Posted by: Guzel sozler at July 12, 2007 10:45 AM

Thanks for help... I will apply this really!

Posted by: arkadaş at July 12, 2007 10:48 AM

Can i translate this and insert on my site in Poland? Thanks

Posted by: Apteka internetowa at July 13, 2007 04:08 PM

You don’t avoid the spam comments. It’s normal when you often posting. ;-)

Posted by: Stock photos at July 13, 2007 04:09 PM

thank you

Posted by: youtube at July 14, 2007 07:44 AM

thanks super site

Posted by: gazeteler at July 14, 2007 12:11 PM

thank you super site thanks

Posted by: gazeteler at July 14, 2007 12:12 PM

good thanks

Posted by: oyun at July 14, 2007 12:12 PM

thank you very good site

Posted by: oyunlar at July 14, 2007 12:12 PM

thank you good

Posted by: gazete at July 14, 2007 12:13 PM

good blog

Posted by: blog at July 14, 2007 12:13 PM

good list thanks

Posted by: toplist at July 14, 2007 12:14 PM

good very gooddd

Posted by: rüya tabileri at July 14, 2007 12:14 PM

very good be

Posted by: izlesene at July 14, 2007 12:15 PM

good video site

Posted by: youtube at July 14, 2007 12:15 PM

thanks macromedia

Posted by: DigitalBoutiques at July 14, 2007 12:41 PM

thanks

Posted by: Directory at July 14, 2007 12:42 PM

thank you

Posted by: Healty at July 14, 2007 12:43 PM

thanks

Posted by: Oyunlar at July 14, 2007 12:43 PM

tnx you

Posted by: sohbet at July 14, 2007 02:33 PM

yeah

Posted by: arama at July 14, 2007 02:50 PM

tnx you yea

Posted by: chat at July 14, 2007 02:52 PM

good very gooddd

Posted by: adult at July 14, 2007 02:52 PM

thnks a lot ..

for sharing your code with community.

Posted by: youtube video izlesene at July 16, 2007 02:26 PM

Ohh thanks , ı agree to you I am new learning about netvibes.
accourting to you this is shop is it

Posted by: Sohbet at July 16, 2007 08:20 PM

Thank you for the useful informations.

Posted by: Nieruchomosci komercyjne at July 17, 2007 02:57 PM

Thanks

Posted by: zonenoktaorg odullu seo yarismasi at July 18, 2007 02:58 AM

thanks all

Posted by: sohbet odaları at July 18, 2007 05:09 AM

Hello

Posted by: chat at July 25, 2007 09:38 AM

ı agree to you I am new learning about netvibes.
accourting to you this is shop is it

Posted by: itiraf at July 25, 2007 09:38 AM

thanks Andy

Posted by: resimler at July 26, 2007 12:08 PM

thanks

Posted by: video at July 27, 2007 01:26 AM

Good Design. Thank you Andy.

Posted by: Bala at July 27, 2007 07:30 PM

very nice article...

Posted by: arabalar at July 28, 2007 08:14 AM

Wowwww!!! What a great tip!

I use to my web site: www.WebAjans.Com / Web Tasarım

Thank you for information.

Posted by: web tasarım at July 30, 2007 01:41 AM

very good

Posted by: bilgisayar satış at July 31, 2007 04:50 AM

good.

Posted by: sohbet at July 31, 2007 03:24 PM

thanks

Posted by: 哈根达斯 at August 1, 2007 04:15 AM

thanks

Posted by: 月饼 at August 1, 2007 04:16 AM

Good Design. Thank you Andy.

Posted by: Apteka internetowa at August 2, 2007 03:42 PM

You don’t avoid the spam comments. It’s normal when you often posting. ;-)

Posted by: Bank zdjec at August 2, 2007 03:43 PM

It's very good article. Great site with very good look and perfect information... Thanks

Posted by: Modlitwa at August 2, 2007 03:46 PM

It's very good article.

Posted by: 荣华月饼 at August 4, 2007 12:42 AM

thanks

Posted by: 美心月饼 at August 4, 2007 12:43 AM

thanks

Posted by: 星巴克月饼 at August 4, 2007 12:44 AM

thanks

Posted by: bilgisayar at August 4, 2007 06:36 AM

Can i translate this and insert on my site in Poland? Thanks

Posted by: Nuxe at August 5, 2007 02:10 AM

Can i translate this and insert on my site in Poland? Thanks

Posted by: Nuxe at August 5, 2007 02:10 AM

thanks good

Posted by: kapı at August 7, 2007 05:00 PM

hi all..

Posted by: sohbet at August 9, 2007 01:58 PM

Thanks good

Posted by: dekorasyon at August 13, 2007 05:51 AM

Can i translate this and insert on my site in Poland? Thanks

Posted by: msn şifre kırıcı at August 14, 2007 01:21 PM

It's very good article. Great site with very good look and perfect information... Thanks

Posted by: limewire indir at August 14, 2007 01:22 PM

Thanks good

Posted by: msn dondurucu at August 14, 2007 01:23 PM

thanks good

Posted by: Gta indir at August 14, 2007 01:24 PM

Good Design. Thank you Andy.

Posted by: msn kurban at August 14, 2007 01:25 PM

thanks

Posted by: winamp indir at August 14, 2007 01:26 PM

thanks for desing

Posted by: photoshop indir at August 14, 2007 01:27 PM

thanks

Posted by: photoshop indir at August 14, 2007 01:28 PM

thanks

Posted by: photoshop indir at August 14, 2007 01:30 PM

good

Posted by: gonca at August 16, 2007 05:48 AM

It's very good article. Great site with very good look and perfect information... Thanks

Posted by: Bank zdjec at August 17, 2007 03:03 AM

The whole article is based on assumptions than really far way from reality.
I don't think its an effective way of testing. Just my opinion and can be wrong too. Regards

Posted by: Apteka internetowa at August 17, 2007 03:06 AM

I'd find it interesting to hear his opinions. Plus it's kinda funny to hear the little Dvorak.
thankssssss

Posted by: aydın kız öğrenci yurdu at August 21, 2007 12:01 AM

youtube

Posted by: Lezbiyen at August 21, 2007 02:37 PM

thanksss

Posted by: sohbet odaları at August 22, 2007 01:54 PM

thanks for

Posted by: Pos Software at August 23, 2007 07:00 AM

very good

Posted by: bilgisayar at August 25, 2007 07:55 AM

thanks

Posted by: halkin yildizlari at August 28, 2007 07:09 AM

very good

Posted by: oyunlar at August 28, 2007 07:10 AM

Do you think that Google has this technology ?

Posted by: Muhabbet at September 2, 2007 09:05 AM

Interesting research. Thank you.

Posted by: BABACAN at September 3, 2007 01:38 AM

...

Posted by: sohbet at September 3, 2007 05:13 AM

Thank you for the useful informations. I really enjoyed reading all of your posts. It?s interesting to read ideas, and observations from someone else?s point of view? makes you think more. So please keep up the great work. Best regards...

Posted by: Buy photo at September 4, 2007 04:49 AM

Thank you for the useful informations..

Posted by: Resimler at September 4, 2007 01:23 PM

Thank..

Posted by: seo at September 5, 2007 09:54 AM


thanks good..

http://www.kureselisinmaveekoloji.blogspot.com/
http://www.cesurturk.org/phpBB2/index.php
http://www.cesurturk.org/index.php?ind=kureselisinma
http://www.cesurturk.org/reviews.html
http://www.cesurturk.org
http://www.saboces.gen.tr

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at September 5, 2007 01:35 PM

thanks.

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at September 5, 2007 01:35 PM

thanks

Posted by: Oyun at September 7, 2007 06:59 AM

Thank you for the useful informations..

Posted by: Sevgi at September 7, 2007 07:00 AM

thanks

Posted by: Democrat at September 7, 2007 07:01 AM

thanks

Posted by: Tutorial at September 7, 2007 07:01 AM

thanks

Posted by: Vip at September 7, 2007 07:02 AM

thanks

Posted by: Toplu Email at September 7, 2007 07:03 AM

thanks

Posted by: Video at September 7, 2007 07:03 AM

thanks

Posted by: Clip at September 7, 2007 07:04 AM

Thank you for the useful informations.

Posted by: Rene Furterer at September 8, 2007 04:43 AM

Thank you for the useful informations.

Posted by: Buy photo at September 8, 2007 04:43 AM

Thanks man.

Posted by: Linksarok at September 12, 2007 09:14 AM

It was very useful. Many thanks.

Posted by: Webdesign & SEO at September 12, 2007 09:17 AM

It was very useful. Many thanks.

I agree with

Posted by: IDDesigns.Net, Web Design, Seo at September 12, 2007 10:04 PM

Very good

Thanks..

Posted by: wmwebtr ödüllü seo yarışması at September 12, 2007 10:05 PM

Hey man thanks!

Posted by: seatonfoundation.org at September 12, 2007 10:06 PM

Thanks for very interesting article. btw. I really enjoyed reading all of your posts. It’s interesting to read ideas,
and observations from someone else’s point of view… makes you think more. So please keep up the great work

Posted by: youtube at September 15, 2007 11:20 AM

Really clever idea.

Thanks for sharing your code with community.

Posted by: Fitness Article at September 27, 2007 12:17 PM

very guzel site

Posted by: sohbet at September 27, 2007 10:09 PM

thxx

Posted by: sohbet at September 27, 2007 10:10 PM

Thanks good

Posted by: kale kapı at September 28, 2007 02:12 AM

thanks licve that

Posted by: oyun at September 28, 2007 04:32 AM

like thats

Posted by: oyun at September 28, 2007 04:33 AM

Thanks. Good Article

Posted by: Aldimeola at September 28, 2007 11:16 AM

thank you sir.. good site..

Posted by: sohbet odalari at September 28, 2007 03:53 PM

Thanx for the backlink. :) Godd site

Posted by: Nyomda at September 29, 2007 02:56 AM

yssss

Posted by: hii all</a><a href="http://www.tamdost.com">kim geldi</a> at September 29, 2007 01:26 PM

That's great. It works.

Posted by: Tervezés at October 1, 2007 02:42 AM

thanksss

Posted by: Elisha Cuthbert at October 1, 2007 02:34 PM

thansk....

Posted by: mp3 indir at October 1, 2007 02:41 PM

nice plugin

Posted by: evden eve nakliyat at October 1, 2007 03:03 PM

Thanks for sharing
wispermits.org
stpaulsbells.com

Posted by: Oyunlar at October 2, 2007 05:56 AM

If you are tired, after this article...

Posted by: Paintball at October 2, 2007 06:24 AM

Working in Europe I can imagine that this is going to be a common type of requirement in the future. Therefore I thought it might be worth sharing the approach taken in implementing this

Posted by: mirc at October 2, 2007 06:50 AM

Hello!

Posted by: adult at October 2, 2007 06:52 AM

thanks

Posted by: turunc4u at October 2, 2007 07:24 AM

If you're tired...

Posted by: Paintball at October 2, 2007 07:30 AM

Is is real? Hey, man!

Posted by: Óriásplakát at October 2, 2007 07:31 AM

Yes, of course!

Posted by: Vonalkód at October 2, 2007 07:32 AM

i have some problems with this idea, how can you help me?

Posted by: estetik at October 2, 2007 09:32 AM

thank you great article

Posted by: corlu at October 2, 2007 12:59 PM

thank you good article

Posted by: cokhos at October 2, 2007 01:19 PM

than you

Posted by: sohbet at October 2, 2007 07:01 PM

THANK YOU

Posted by: ozcan at October 2, 2007 11:34 PM

Why do people this?

Posted by: Domain at October 3, 2007 07:09 AM

thanks

Posted by: Free wordpress themes at October 4, 2007 08:27 AM

thanks for the info

Posted by: Download movies at October 5, 2007 11:51 AM

Excellent! I useful for my web page!

Thank you...

Minna Lazer Epilasyon - Lazerli Epilasyon

Posted by: Lazerli Epilasyon at October 5, 2007 12:26 PM

This one of the major problems for the multilanguage websites.Thanks for the article.I'm sure it will make things easier for most of us

Posted by: video izle at October 5, 2007 02:28 PM

thanks your article ready

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at October 5, 2007 04:11 PM

Msn İfadeleri thank you

Posted by: Msn İfadeleri at October 7, 2007 01:39 PM

www.nfsprostreet.org

Posted by: nfs pro street download at October 9, 2007 09:20 AM

Excellent! Udeful for my web page!

Posted by: Netsarok at October 10, 2007 12:48 AM

thank you article ready...

Posted by: fullserial at October 10, 2007 07:00 AM

thank you

Posted by: Sağlık at October 10, 2007 07:06 AM

thank you

Posted by: Sağlık Siteleri at October 10, 2007 07:07 AM

thank you

Posted by: Varista at October 10, 2007 07:09 AM

thank you

Posted by: Sağlık Terimleri at October 10, 2007 07:10 AM

thank you

Posted by: Alerji at October 10, 2007 07:10 AM

thank you

Posted by: Sağlık Defteri at October 10, 2007 07:12 AM

thank you

Posted by: Sağlık Siteleri Dizini at October 10, 2007 07:13 AM

thank you

Posted by: Webmaster Blog at October 10, 2007 07:13 AM

thank you

Posted by: Merve Boluğur at October 10, 2007 07:14 AM

thank you

Posted by: Cilt Bakımı at October 10, 2007 07:14 AM

thank you

Posted by: Yemek Tarifleri at October 10, 2007 07:15 AM

Thanks

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at October 12, 2007 01:21 PM

Thanks.

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at October 12, 2007 01:22 PM

Thank you

Posted by: drcetinerdotorg at October 12, 2007 01:23 PM

Thank you

Posted by: grafiker at October 12, 2007 01:25 PM

thanks

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at October 16, 2007 10:40 AM

thanks..

Posted by: sohbet at October 17, 2007 02:47 PM

great post thank you

Posted by: burclar at October 18, 2007 04:53 AM

thanks canım

Posted by: www.r10.net küresel ısınmaya hayır seo yarışması at October 18, 2007 10:35 AM

THANSK ADAMIMM

Posted by: küresel ısınma at October 18, 2007 10:42 AM

thanks

Posted by: kurtlar vadisi pusu videoları at October 18, 2007 10:45 AM

thank you

Posted by: Cokhos at October 18, 2007 01:47 PM

good thankss

Posted by: bedava videolar at October 19, 2007 07:41 AM

good thankss

Posted by: sohbet at October 19, 2007 07:42 AM

good thankss

Posted by: sohbet at October 19, 2007 07:43 AM

good thankss

Posted by: chat at October 19, 2007 07:44 AM

Post a comment




Remember Me?