PDA

View Full Version : International Coding



blueclue7
12-08-2004, 11:32 PM
I learned of this forum while studying the code for a website that comes in a couple "flavors" -- english and russian. See: www.dolcevitacrimea.com

I find that it is common on international sites for the user/client to have to select his native language through a button selection. The website I noted above is an example.

Is there no way to automate this process -- detect the native language for the web browser or system, and then load the appropriate text tables or resource files? It seems like there should be some script to handle this. I know that Java has a system resource class, but I would like to steer away from java and javascript if possible. Any thoughts?

cr3ative
12-09-2004, 11:35 AM
Put this in the <head> section of your index.htm file (keep that file blank other than the HTML essentials)


<SCRIPT language="javascript">
language=navigator.language;
if(language){language=language.substring(0,2);}
else{language="z";}
switch (language){
case "en" :
window.location="english.html";
break;
case "es" :
window.location="spanish.html";
break;
case "de" :
window.location="german.html";
break;
case "fr" :
window.location="french.html";
break;
case "it" :
window.location="italian.html";
break;
case "sv" :
window.location="swedish.html";
break;
case "nl" :
window.location="dutch.html";
break;
default :
window.location="english.html";

}
</SCRIPT>

And then it'll instantly redirect to english.htm, dutch.htm, swedish.htm, italian.htm, german.htm or spanish.htm according to browser language.

cr3ative