Change the language of your website
If you have ever changed the language of a website that you have visited, you would have noticed that some websites prefer to ask you from which country you are from before changing the language and others prefer to ask you directly what language you wish to display the website. However, there is also a code that you can insert in a PHP file that will automatically detect the server that is being used by the visitor, and hence apply the changes in the language accordingly.
<?
if (!isset($Language)) {
$Language = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Language[0]),0,2));
}
?>
The web master will have the choice to either redirect the visitor to another webpage that is linked to the website but that corresponds to the visitor’s needs in term of language, else, the webmaster can activate a configuration file that will translate the contents that have been displayed on the original page.
Option 1:
<? else {
header("Location: /index.php?Language=en");
} ?>
Option 2:
<?
include("language-".$Language.".inc.php");
?>