Re: [Dan Maitland] Multilanguage support
Hi,
It looks like you're using one header if it's an English Page and one header if it's a French page. Is that right?
If so, what you can do is set up an array of file names in your header file, using the file name of one language as an index and the file name of the other language as the value.
For example, here is an array you could put in your English Header using English names as an index and French names as a value:
NOTE, this is only an example and won't include all file name you'll need on your site.
//create English to French array
$englishToFrench = array();
$englishToFrench['home.php']="index.php";
$englishToFrench['properties.php']="proprietes.php";
$englishToFrench['about.php']="a-propos-de-gold-castle.php";
$englishToFrench['contact.php']="contactez-nous.php";
$englishToFrench['property.php']="proprietie.php";
Next we need to get the name of the current PHP file being displayed:
//get current file name.
$path = explode("/",$_SERVER['SCRIPT_NAME']);
$fileName = trim($path[count($path)-1]);
Now we can use the current file name to get the french equivalent. (If it's not there, we'll default to the home page.)
if(!@$englishToFrench[$fileName]){
$link="index.php";
}
else{
$link = $englishToFrench[$fileName];
}
Finally, we can add any url variables to the link string if they exist.
/add url variables
$urlString = "";
foreach($_REQUEST as $key=>$value){
if($urlString){
$urlString.="&$key=$value";
}
else{
$urlString="$key=$value";
}
}
if($urlString){
$link.="?$urlString";
}
All we have to do now is use $link in our <a> tag:
<a href="<?php echo $link;?>">Français</a>
Give this a try, it should get you started.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/