i, i m trying to create this script to be used in dual language site
like we can switch from English version (in /en/ directory) to ... let's
say Indonesia version (in /id/ directory). The files in that 2 directoties
are just the same, differ only in their language.
I got tis script from internet, but it doesn't seem to work.
I am a beginner in php and i tried to 'fix' the script, but
it still won't work 🙁
here's the script :
<?php
function getLink() {
global $SERVER;
$lnk = $SERVER['PHP_SELF'];
if ($SERVER['QUERY_STRING']!="") {
$lnk .= $SERVER['QUERY_STRING'];
}
$lnktxt = "Switch to ";
if (is_int(strpos($lnk,"/en/"))) {
$lnk = str_replace("/en/","/id/",$lnk);
$lnktxt .= "Indonesia";
} elseif (is_int(strpos($lnk,"/id/"))) {
$lnk = str_replace("/id/","/en/",$lnk);
$lnktxt .= "English";
}
$lnk .= "<a href=\"$lnk\">$lnktxt</a>";
echo "<br>";
return $lnk;
}
?>
<?=getLink();?>
regards,
ika