PHP multi-Language Help needed guys.... :(
Posted: Mon Jul 26, 2010 7:51 pm
Guys i am new to PHP and have created a simple multi-language website.It is using a very basic logic to change the languages.
It works based on $_GET so to hold the language as it is i have to protect the URL as "www.blablabla.com/index.php?lang=en" for English or "www.blablabla.com/index.php?lang=jp" for Japanees.But guys when i put a link inside the main page to a sub page the URL get change like "www.blablabla.com/sub.php".After that website doesn't work because URL does not provide a value to that $_Get function
This is the language switching logic.
To hold a one language all around my website, selected by the visitor what should i do?.How to protect that lang=en in the URL every time in a new Link?.
Please give me a idea to solve my problem.
It works based on $_GET so to hold the language as it is i have to protect the URL as "www.blablabla.com/index.php?lang=en" for English or "www.blablabla.com/index.php?lang=jp" for Japanees.But guys when i put a link inside the main page to a sub page the URL get change like "www.blablabla.com/sub.php".After that website doesn't work because URL does not provide a value to that $_Get function
This is the language switching logic.
Code: Select all
if(isset($_GET['lang']))
{
$lang=$_GET['lang'];
}
else
{
$lang='en';
}
switch ($lang)
{
case 'en';
$lang_file = 'en.php';
break;
case 'jp';
$lang_file = 'jp.php';
break;
default;
$lang_file = 'en.php';
}Please give me a idea to solve my problem.