I've a little problem with a function SwitchLang, for my website I have two languages, French and English.
All the pages on my site have the same name in french and english and the only distinction is :
website.com/fr/about/
website.com/en/about/
So I've search on the Internet and I've found this piece of code :
Code:
<?php function switchLang ($mode) { if($mode==="fr"){ $posfr = strpos($_SERVER['REDIRECT_URL'],"/fr/"); $part1=substr($_SERVER['REDIRECT_URL'],0,$posfr); $part2=substr($_SERVER['REDIRECT_URL'],$posfr+4); $link2=$part1."/en/".$part2; $return="<li><a href=\"".$part1."/fr\">Fr</a></li>"; $return.="<li><a href=\"".$link2."\">En</a></li>"; } elseif($mode==="en") { $posen = strpos($_SERVER['PHP_SELF'],"/en/"); $part1=substr($_SERVER['PHP_SELF'],0,$posen); $part2=substr($_SERVER['PHP_SELF'],$posen+4); $link=$part1."/fr/".$part2; $return="<li><a href=\"".$link."\">Fr</a></li>"; $return.="<li><a href=\"".$part1."/en\">En</a></li>"; } else { $return="<li><a href=\"/fr\">Fr</a></li>"; $return.="<li><a href=\"/en\">En</a></li>"; } return $return; } ?>
The other problem is that my flag button for switch is in the $logo_area in the bfa_header_config.php, so when I put the code :
Code:
<a href="<?php echo switchLang(\'fr\'); ?>"><img src="/flag.png"></a>
Can somebody help me to solve this problem?
Regards, Lyryanne =).
PS : Sorry for my poor English I'm French ^^.