PHP Flash browser language detection – Works on Internet Explorer too! (BUG FIX Workaround!!).
Demo of it working inside IE & FF 
CODE
php/page code
<script type="text/javascript" src="swfobject.js"></script>
<div id="flashcontent">
Update Flash Player or <a href="?detectflash=false">bypass detection</a>.
</div>
<script type="text/javascript">
var so = new SWFObject("core.swf", "core", "300", "300", "9", "#333");
so.addVariable("langX",
<?
//////////////////////////////////////
// langX by Kurt Grung | 3L3373.com //
//////////////////////////////////////
$lang = getenv ("HTTP_ACCEPT_LANGUAGE");
$set_lang = explode(',', $lang);
$i = 0;
while ($i < 1) {
$code = substr("$set_lang[$i]", 0, 2);
echo "\"".$code."\"";
$i++;
}
?>
);
so.write("flashcontent");
</script>
Here are a few other snippets of code to detect which language version the user has set.
//as code
//langX
//by kurt grung 3l3373.com
var lang = System.capabilities.language;
trace(lang)if (lang == "en"){
clip.loadMovie("en.swf");
} else if (lang == "jp") {
clip.loadMovie("jp.swf");
}
a lowercase two-letter language code from ISO 639-1, flash supports the following subset of the language tags:
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary710.html
downfall for using flash “System.capabilities.language” is that is only pulls the install lanague the OS has installed not what the browser has set. however PHP can extract the enviroment code of “HTTP_ACCEPT_LANGUAGE” (throught teh headers) to check the users browser language version which has been set regardless of the language installed/set inside the OS.
‘getenv’ is the function – http://uk.php.net/manual/en/function.getenv.php
list ISO 639 Language Codes – http://www.w3.org/WAI/ER/IG/ert/iso639.htm
//php code
//langX
//by kurt grung 3l3373.com
$lang = getenv ("HTTP_ACCEPT_LANGUAGE");
$set_lang = explode(',', $lang);
$i = 0;
while ($i < 1) {
$code = substr("$set_lang[$i]", 0, 2);
/*
if ($code == 'en'){
print("english");
}
elseif ($code == 'af'){
print("afrikaans");
}
else{
echo 'lang? '.$code.'';
}
*/
echo 'langX = '.$code.'';
$i++;
}
here is a example how to do this in javascript to.
//js code
//langX
//by kurt grung 3l3373.com
var nav_lng="1337"; //default language string
if(navigator.language)nav_lng=navigator.language;
if(navigator.browserlanguage)nav_lng=navigator.userLanguage;
if(navigator.systemLanguage)nav_lng=navigator.systemLanguage;
if(navigator.browserlanguage)nav_lng=navigator.browserlanguage;
if(navigator.userLanguage)nav_lng=navigator.userLanguage;
if(window.navigator.language)nav_lng=window.navigator.language;
var varsX=''+nav_lng;
document.write(varsX);
var ua = navigator.userAgent.toLowerCase();
var is_pc_ie = ( (ua.indexOf('msie') != -1 ) && ( ua.indexOf('win') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('webtv') == -1 ) );
//asp code
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<%
Dim userLocale
userLocale = request.servervariables("HTTP_ACCEPT_LANGUAGE")
Response.Write "Language string: " & userLocale & ""
More here
(ASP) http://support.microsoft.com/kb/315616
***FLASH HTTP_ACCEPT_LANGUAGE loadVars Bug*** I have tried this in both AS2/3 both aren’t working..
My posts @ actionscript.org;
“using php “HTTP_ACCEPT_LANGUAGE” pull into flash, working perfectly fine on firefox, ie doesn’t load the correct browser preferance – just seems to default to en-US all the time. and when I load the php standalone it displays correct lang preference – does anybody know why this might be happening tried everything?”
“i have been looking into this issue/bug, found no answers tried so many workarounds – Cookies / Flash remoting (AMFPHP/phpObject/FMS) nothing works… IE is just s*&^t < thats my conlusion ;o”
Possible workaround for this would be using JavaScript and a dynamic scripting call to “HTTP_ACCEPT_LANGUAGE” then passing these variables through to flash using the flashVars implimentation like SWFObject “so.addVariable(“var”, “val”);” etc.. you could either do either a Switch statement in JavaScript or Flash.
Great got it working check the demo above
or… http://3l3373.com/dl/tutorials/langX/
More
http://blog.deconcept.com/swfobject/#examples (SWFOBject)
SWFobject latest