My current project is Multilingual in :
- Arabic
- English
I'm working one making custom language switcher with Qtranslate plugin.And this is what I want to do:
- At English Content, user want to press on language URL for the Arabic language only, so that he switch to the Arabic version.
- At Arabic Content, user want to press on language URL for the English language only, so that he switch to the English version.
What I did, I appended to the header.php after wordpress call the menu this code:
<?php
$current_lang=qtranxf_getLanguage();
if($current_lang=="ar"){
echo "<li class='menu-item menu-item-type-custom'>". " <a class ='qtranxs_flag_en qtranxs_flag_and_text' href='http://127.0.0.1/idevlab.com/comtec.com/idevtra/'>Englsih</a>"."</li>";
}else{
echo "<li class='menu-item menu-item-type-custom'>". " <a class ='qtranxs_flag_ar qtranxs_flag_and_text' href='http://127.0.0.1/idevlab.com/comtec.com/idevtra/ar'>العربية</a>"."</li>";
}
?>
But, the URL appears well, but unfortunately it reloads the website to the current content not to the other synchronized content.
I tried to inspect the element of the widgets and I could only figure that they use this class in the URL for the language switcher ,
<a class ='qtranxs_flag_en qtranxs_flag_and_text
But, it do nothing with my and it seems that it calls the last cashed language from the browser or the DB and I don't know how ?
So, I'd be highly appreciated if you could guide/help me to make this costume language switcher.
Add a custom link menu item with the following code as url:
Leave the other fields empty.