View Full Version : Approaches for language selection for a website
dail
September 18th, 2008, 04:35 AM
Hi,
So, I've got a new little site to implement, that has the requirement of supporting 3 different languages, via the user choosing their language on the sites landing page.
It's not something I've implemented as of yet, so I'm interested in what best approaches or techniques apply for generating this type of functionality.
I imagine storing the language files as XML and loading in as requested. I guess I'm interested in the best method for developing a site that supports swapping a language for all text elements on the fly. Mook has a rough sketch of an approach using namespaces, is this something I should investigate.
Thanks in advance.
Pier25
September 18th, 2008, 05:12 AM
What we do is to have a cookie, so that everytime we call a dynamic xml the php/asp checks which language is and returns the xml in that language.
You could also pass a var to flash using flashvars, and then append the language code (en, es, fr, de, jp etc) in the url of the dyanmic xml called from inside flash. www.mydomain.com/xml/mydata.xml.php?lang=en
Then of course in the database we have a field for every language: name_en, name_es, name_fr in the same table.
For HTML sites, switching languages is easy. Just change the lang var and reload the page. For flash sites you could reload the xml, and reload that particular section/menu/etc but it's a pain to do that IMO, and frankly 99,99% of users won't change the language on the fly once they have chosen it on the landing page. So what we do is simply reload the main swf and start the whole process again, with different xml.
dail
September 18th, 2008, 03:29 PM
Cheers for your input Pier25.
The project I have wont be a database driven site unfortunately, but it will definitely use XML throughout. I agree, most users wont change languages once they have set it on the landing page.
creatify
September 18th, 2008, 08:22 PM
The big thing to clear-up at the beginning, is if your app allows viewers to change the language whilst in the middle of a sub page or something like that vs. just selecting language from the get-go (or if language is automatically selected).
Swopping languages in the midst of runtime - that's a pain. But, just having the user select their language up front, then set a path to that language's XML folder is your best bet, and works out well. Keep in mind, if you have embedded fonts, those fonts may or may not display all the extra language glyphs. With Japanese or Chinese, you'll usually have to default to a non-embedded system font - which, in planning, means you won't be able to easily run alpha or other animations on that dynamic text.
Also, I've never played with this, but this seems interesting: http://www.adobe.com/devnet/flash/articles/text_localization_print.html
Hope this helps.
jmalko
September 19th, 2008, 12:56 PM
This may be the noobest thing ever, but I do have a language selection that includes 7 languages. The client requested that they change on the fly. For some elements, I'll reload XML (like lists for videos and such), but for everything else, I just have a really large switch { } inside a language - change function. It didn't take all that long to set up and update... But I guess it really depends on what you're doing.
dail
September 21st, 2008, 05:12 AM
Cheers for that link Creatify. Looks interesting!
The client wants both approaches, setting the language at the start, and at any other time as well.
nortago
September 21st, 2008, 07:03 AM
I worked on something recently where by the user would choose their language up front but it would use swfAddress to point to http://www.siteexample.com/#/en, and from there it would take the en var and load in either the en.xml or filter out te 'en' nodes in the xml...
dail
September 27th, 2008, 10:42 PM
In the end I've set up an Interface that any classes that need to change their language implement. It contains a simple setLanguage method. Each class then runs that method when they are instantiated. To handle the need for runtime language changing I've set up an event, that again, all classes that need to listen for. If they have to change their language, they call that setLanguage method, then call a method that adjusts the interface to take into account for the new dimensions of all the relevant text fields.
I'm storing the relevant XML in a static var.
Seems to be working fine so far.
Pier25
October 29th, 2008, 11:37 AM
With Japanese or Chinese, you'll usually have to default to a non-embedded system font
And... how do you do that?
creatify
October 29th, 2008, 06:36 PM
In the end I've set up an Interface that any classes that need to change their language implement. .....
That's a cool solution, like a mini font Observer of sorts. I'll have to play with that approach next multi-language project.
With Japanese or Chinese, you'll usually have to default to a non-embedded system fontAnd... how do you do that?
There are many ways, depending on if you're text is styled via TextFormat or CSS. If in css, you just set the fonts in the style to regular system fonts and then set embed = false on your dynamic textField. You can do the similar thing with TextFormat.
Pier25
October 30th, 2008, 05:08 AM
There are many ways, depending on if you're text is styled via TextFormat or CSS. If in css, you just set the fonts in the style to regular system fonts and then set embed = false on your dynamic textField. You can do the similar thing with TextFormat.
Thanks for the info!
Do you have any working example?
Regards
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.