Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-26-2008, 04:23 PM   #1
euroq
Registered User
 
Join Date: Feb 2008
Posts: 7
Default Auto-detect browser's language

Hello,

In javascript you can use
Code:
	    var lan = ((navigator.browserLanguage) ? 
	                navigator.browserLanguage : 
	                (navigator.language) ? navigator.language : navigator.userLanguage);
which will produce something like "EN-us" for American English or "PT-br" Brazilian Portuguese. Does anyone know of a way to dynamically discover the user's language in flash? Either through a similar property, or an operating system property?

Thanks!
euroq is offline   Reply With Quote
Old 02-26-2008, 05:37 PM   #2
panel
AS3
 
panel's Avatar
 
Join Date: Mar 2007
Location: Warsaw
Posts: 1,991
Send a message via Skype™ to panel
Default

ActionScript Code:
Capabilities.language
panel is offline   Reply With Quote
Old 02-28-2008, 09:03 PM   #3
roidelapatate
Registered User
 
Join Date: Feb 2008
Posts: 5
Default

Capabilities.language seems to reflect the language setting of the OS. Is there any way to get the browser language preference?
Cheers.
roidelapatate is offline   Reply With Quote
Old 02-29-2008, 03:53 AM   #4
sgartner
Senior Member
 
Join Date: Jan 2008
Location: Boise, ID
Posts: 227
Default

Quote:
Originally Posted by euroq View Post
Hello,

In javascript you can use
Code:
	    var lan = ((navigator.browserLanguage) ? 
	                navigator.browserLanguage : 
	                (navigator.language) ? navigator.language : navigator.userLanguage);
which will produce something like "EN-us" for American English or "PT-br" Brazilian Portuguese. Does anyone know of a way to dynamically discover the user's language in flash? Either through a similar property, or an operating system property?

Thanks!
You could just create the flashVars dynamically in JavaScript as the page loads and pass in the browser language that way. Or inside Flash you could use ExternalInterface to communicate with the container and pull essentially the same variables.
sgartner is offline   Reply With Quote
Old 04-12-2010, 09:41 PM   #5
Tereba
Lost in Script...
 
Tereba's Avatar
 
Join Date: Sep 2008
Posts: 86
Default Auto-detect browser's language - same issue

Quote:
Originally Posted by roidelapatate View Post
Capabilities.language seems to reflect the language setting of the OS. Is there any way to get the browser language preference?
Cheers.
hey roidelapatate,
did you manage to find the way to get the browser language preference into Flash ?
I have the same issue, where I would like to change the website's language to english or portuguese, depending of the browser language preference...
Thanks
Tereba is offline   Reply With Quote
Old 04-12-2010, 11:23 PM   #6
Arodicus
Senior Member
 
Join Date: Nov 2002
Location: CA
Posts: 454
Default Solution: ExternalInterface

Read my article on JavaScript Injection for one method of doing this through ActionScript 3's ExternalInterface Class.

Ignore the very first comment that claims it "no longer works" - the guy who wrote it didn't actually read the article

It's fairly easy to do, works fine in all browsers, and opens up the entire browser javascript environment to ActionScript.
Arodicus is offline   Reply With Quote
Old 04-20-2010, 01:59 AM   #7
Tereba
Lost in Script...
 
Tereba's Avatar
 
Join Date: Sep 2008
Posts: 86
Default

Thank you very much for stepping in Arodicus!
I decided to go the easy way - determining the language via OS.
My solution, to those who may have the same need, is:

Code:
if (System.capabilities.language == "pt") {		
			do something if language is portuguese;
		} else {
			do something else if language is not portuguese;
		}
I only appologize that the solution is for AS2, and I just realized this is the AS3 section of the forum... ... am not sure how this behaves for AS3...
best regards
Tereba
Tereba is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to auto detect and auto install for the Flash player 9,if the player? tanusree HTML and JavaScript 4 02-07-2008 12:36 PM
Auto format dynamic text in foreign language ? yoes_san ActionScript 2.0 1 12-08-2006 04:18 AM
flash detect in all browsers polluxrob ActionScript 1.0 (and below) 1 06-13-2006 01:33 PM
Detect IE, Nav or other browsers Xirco ActionScript 1.0 (and below) 2 04-14-2004 02:09 PM
Auto Detect Project vs. Player JDWolff ActionScript 2.0 5 03-23-2004 06:38 PM


All times are GMT. The time now is 11:32 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.