Today i put all the links on the webpage, but still don’t work.
Behind I see the way that the pages have two or more languages, giving to the user the choice.
Now I made that the language has been choose automatically.
How it works?
Take the language that the Internet browser has been configured and tell to the webpage to it put in that language (if we have avaible the language).
This save some values time of our life.
* In the case that the users don’t configure the browser language appropriately, the language can be change at the final of this page.
The development is very simple, i put the script on the line 0 on my index. If you want to use my script you can see it now:
<?php // The variable $SERVER['HTTP_ACCEPT_LANGUAGE'] give us the language of the browser in the code of the same browser.
$language_browser = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
// This code take the first two letters of the variable $language_browser In this case this are different even each language. Example: “en” english.
$language_browser_new = substr($language_browser, 0, 2);
// Now make a condition, $language_browser_new have our language, if this are equal to “es”, make the variable $language equal to “es”, if it is equal to “en”, make the variable equal to “en”, but in case that are not of this (because the language’s are not avaibles) make the variable equal to “en” (English, our predetermined language). if($language_browser_new=="es"){ $language = "es"; } else {
if($language_browser_new=="en"){ $language = "en"; } else { $language = "en"; }
} ?>
Then, here finish our code.
* Remember that here I need that make equal the language, but in your case you can use the function header to redirect to some page, example: english.php .
My languages url’s are the next:
http://www.zseven.net/en - English
http://www.zseven.net/es - Spanish
We hope that some day expand this.