[flexcoders] How to get the right locale in IE?
I'm trying to get the locale from IE 9. I've written the following, but it is not working as expected. In IE 9, I can add more than one language, so I can add [de], then [de_DE], then [en_US] (listed in that order). If I call 'navigator.userLanguage.toString', then IE returns en-us, even though I know German is listed first and working (Google comes up in German). I thought maybe it was because it was trying to return an Array of languages, so I changed my code to look for an Array or an Object. Nothing works. var l10NCodes:Object = null; var l10nCode:String = null; /* Try to get the language code from the browser first. The browser returns both the language code and the country code rather than just the language code alone. */ if (ExternalInterface.available) { l10NCodes = ExternalInterface.call('navigator.userLanguage'); l10nCode = ExternalInterface.call('navigator.userLanguage.toString'); } Michael J. Regert
Re: [flexcoders] How to get the right locale in IE?
The first thing I’d do is write a test html page with some JS and try to get it to alert the right answer. On 12/15/11 1:22 PM, michael_reg...@dell.com michael_reg...@dell.com wrote: I’m trying to get the locale from IE 9. I’ve written the following, but it is not working as expected. In IE 9, I can add more than one language, so I can add [de], then [de_DE], then [en_US] (listed in that order). If I call 'navigator.userLanguage.toString', then IE returns en-us, even though I know German is listed first and working (Google comes up in German). I thought maybe it was because it was trying to return an Array of languages, so I changed my code to look for an Array or an Object. Nothing works. var l10NCodes:Object = null; var l10nCode:String = null; /* Try to get the language code from the browser first. The browser returns both the language code and the country code rather than just the language code alone. */ if (ExternalInterface.available) { l10NCodes = ExternalInterface.call('navigator.userLanguage'); ! ; l10nCode = ExternalInterface.call('navigator.userLanguage.toString'); } Michael J. Regert -- Alex Harui Flex SDK Team Adobe System, Inc. http://blogs.adobe.com/aharui
Re: [flexcoders] How to get the right locale in IE?
On 12/16/2011 4:22 AM, michael_reg...@dell.com said: I’m trying to get the locale from IE 9. I’ve written the following, but it is not working as expected. In IE 9, I can add more than one language, so I can add [de], then [de_DE], then [en_US] (listed in that order). if you have something server side, i'd parse HTTP_ACCEPT_LANGUAGE return that to your flex app.
Re: [flexcoders] How to get the right locale in IE?
oops, and you might also look at IP to location/locale as well.