I'm trying to use a script to select a language from a form.
No matter what I select, the language file does not change. when i manually set the language ($lang = 'english' or $lang = 'dutch') then the correct language file is loaded.
Can anyone help me out on this? (just adjusting the code without dismissing my code altogether and suggesting something completely different)
Code:<?php session_start(); ?> <?php function check_lang() { //make sure that we have a language selected by using session .. if (!isset($_SESSION['lang'])) { /* you can either show error message and terminate script die('No language was selected! please go back and choose a langauge!');*/ //or set a default language $lang = 'english'; } else { $lang = $_SESSION['lang']; } //directory name $dir = 'languages'; //now we return the langauge wanted ! //Returned String Format: dirname/filename.ext return "$dir/$lang.lng"; } ?> <div id="langsel"> <form action="index.php" method="get"> <select name="lang" onchange="this.form.submit();"> <option value="english">English</option> <option value="dutch">Nederlands</option> </select> </form> </div> <?PHP //this function will check user language and return the file name to be included .. $lang = check_lang(); include_once($lang); ?>



Reply With Quote

Bookmarks