Im working on a website and wanted to make it multy language.
I found a multy lamguage script on the internet.
I added the files and the php redirect to my site.
It works fine for the pages in my root dir but it doesnt seem to work on the php files located in other dirs in my root.
root/main.php works fine but root/admin/admin.php aint working.
it gives an error that the server cant find my lang file.
my lang files are located in root/lang/ and the php script is located in root/include/session.php.
here a copy of the script
session_start();
if(isSet($_GET['lang']))
{
$lang = $_GET['lang'];
// register the session and set the cookie
$_SESSION['lang'] = $lang;
setcookie("lang", $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'en';
}
switch ($lang) {
case 'en':
$lang_file = 'lang.en.php';
break;
case 'nl':
$lang_file = 'lang.nl.php';
break;
default:
$lang_file = 'lang.en.php';
}
include_once 'lang/'.$lang_file;
You have just to include with a relative path, relative to the current script (session.php)