Version: 0.01

Type: Sample Code (HOWTO)

Category: Other

License: GNU General Public License

Description: Redirects to the right translation of your site, dependent on the browsers language settings. It takes into account the order of user's language preference.



<?php
$lang=strtok($HTTP_ACCEPT_LANGUAGE,","); //language codes are comma delimited
while ($lang){
 if (strstr($lang,"en")){ //if there is "en" in it
  header ("Location: http://your.domain.com/english/"); 
  exit;}
 if (strstr($lang,"es")){
  header ("Location: http://your.domain.com/castellano/"); 
  exit;}
 if (strstr($lang,"nl"){
  header ("Location: http://your.domain.com/nederlands/"); 
  exit;}
 if ereg((strstr($lang,"de"){
  header ("Location: http://your.domain.com/deutsch/"); 
  exit;}
 $lang=strtok(",");}//next token and end of while
header ("Location: http://your.domain.com/english/"); // default relocation in case nothing got detected
exit;
?>