php multilanguage site..code missing please help
Posted: Wed Sep 23, 2009 2:01 pm
I have 2 folders(english & german) with complete translated text, etc. I need to create the website in such a way that if a user clicks on their preferred language even if they r deep within the page, the translation will simply translate that current page and not take the user to the start page of their preferred language like what I currently have. Yesterday somebody gave me a clue with 4 points which are:
1. Check if the "change Language" option was POSTED.
2. If yes, then get the current URL
3. Modify the current URL to the other language equivalent
4. Do a header redirect to the new URL
following that I came up with the following codes and I am stuck on number 3 which I need help on.
i could hv easily done this with mysql but i cant becoz of circumstances beyond my control. thank you for helping me.
1. Check if the "change Language" option was POSTED.
2. If yes, then get the current URL
3. Modify the current URL to the other language equivalent
4. Do a header redirect to the new URL
following that I came up with the following codes and I am stuck on number 3 which I need help on.
Code: Select all
1. CHECK IF THE "change Language" OPTION WAS POSTED.
<a href="index.html?lang=en"><img src="images/en.png" /></a>
<a href="index.html?lang=de"><img src="images/de.png" /></a>
2. IF YES, THEN GET THE CURRENT URL
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
3. MODIFY THE CURRENT URL TO THE OTHER LANGUAGE EQUIVALENT
I am stuck here. please help me how can i modify the currentURL to the other equivalent. I have hundreds of pages and i am clueless really.
4. Do a header redirect to the new URL
<?php
header("Location: http://mygerman site/");
exit();
?>