[PHP] Redirect depending on specific language

Last update on August 7, 2009 07:13 PM by jak58
Published by jak58

[PHP] Redirect depending on specific language









Many sites require that you choose the language by clicking on an icon for the country. It is possible to detect the default language of the visitor through the information provided by the browser (languages: $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE']:

<?
if (!isset($Language)) {
$Language = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Language[0]),0,2));
}
?>


Depending on the language of your visitor you can,:
  • The redirect to a specific page:


<? else {
header("Location: /index.php?Language=en");
}  ?>
  • Include a configuration file containing translations of the selected language:

<? 
include("language-".$Langue.".inc.php");
 ?>
Best answers for « Redirect depending on specific language » in :
Characteristics of programming languages Show There are many programming languages, each corresponding to specific needs (formula calculus, character string processing, real-time, etc.) with each having specific characteristics and functionalities. Therefore, the choice of programming language...
Redirect to a webpage Show Redirect to a webpage htaccess Using php header Using a meta tag Using JavaScript Here below you should get an explanantion on how to redirect to a web page using.htaccess or JavaScript htaccess The .htaccess is to be placed in the...
How to change the language on Facebook? ShowHow to change the language on Facebook? This tutorial will help you to change the language on Facebook if you never tried to do to is successfully: • Open facebook on your browser : http://www.facebook.com. • In the bottom left of...
How to access Google in your preferred language? ShowHow to access Google in your preferred language? Google is an American corporation with main activity as publishing advertising. To expand its numbers of users on a global scale, Google has extended as a multi-language website enabling you to surf...
Keyboard shortcut to change language ShowKeyboard shortcut to change language Issue Is there a keyboard shortcut to change language, instead of going through the language menu on the taskbar? Solution Just press Alt + SHIFT simultaneously
Download Everest Dictionary ShowEverest Dictionary is the biggest free dictionary. It includes 35 modules of different languages. These main characteristics: the support of all common international languages, the possibility of searching words by using several dictionaries all...
Download Foxit Reader ShowFoxit Reader is a free PDF document viewer and printer, with incredible small size. Features: Multi-language Input Capture words via mouse Search PDF in another way Minimize Foxit Reader to the system tray Work with friendly bookmarks ...
Programming languages ShowProgramming language A "programming language" is a language designed to describe a set of consecutive actions to be executed by a computer. A programming language is therefore a practical way for us (humans) to give instructions to a...
Specifications ShowInterest of specifications "Specifications" refer to a contractual document describing what is expectd of the contractor by the client. It is a document that describes, as precisely as possible, in simple terms, the needs that the contractor must...
FTP protocol (File Transfer Protocol) ShowIntroduction to FTP protocol FTP protocol (File Transfer Protocol) is, as its name indicates a protocol for transferring files. The implementation of FTP dates from 1971 when a file transfer system (described in RFC141) between MIT machines...