I was wondering how I could make users of a website change the language of the site. If for example I would have 2 language files:
lang_eng.php
lang_de.php
with all the language variables in there. I was thinking about having a drop down box on top of the site where users could change the language of the site. How would I make my site chose the language file corresponding to the language which is selected by the user?
Could you please tell me how I could achieve this, thanks.
zit, make the dropdown form, action="changeLang.php"
next, you will need to either use a cookie/session to store their language choice, or put it in the URL
PHP Code:
/* changeLang.php */
$_SESSION['Language'] = $_POST['Language'];
// setcookie("Language", $_POST['Language'], time() + 3600);
// URL method will require you to add the QUERY STRING to all pages. might get tough
if($Language == 'English') {
include 'English.php';
}
/* SomePage.php */
echo $Lang['SiteName']; // if they included English.php, this variable will be set as PT, if they included Other.php, it will be set as Lhsd