I have this code but it's not working because the current_language variable only updates upon page load and the gTranslate options do not reload the page
<input type="button" id="YourButtonES" value="Español" />
<input type="button" id="YourButtonEN" value="Inglés" />
<script>
buttonES = document.getElementById("YourButtonES");
buttonEN = document.getElementById("YourButtonEN");
buttonES.style.visibility = 'visible';
buttonEN.style.visibility = 'hidden';
var current_language = gt_get_cookie('googtrans').split('/').pop();
console.log("current lang " + current_language);
if (current_language === 'es') {
buttonES.style.visibility = 'hidden';
buttonEN.style.visibility = 'visible';
} else {
buttonES.style.visibility = 'visible';
buttonEN.style.visibility = 'hidden';
}
//GTranslate code
function gt_get_cookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
console.log(name.length);
return c.substring(name.length, c.length);
}
}
console.log('return');
return "";
}
</script>
URL: https://staging.alanonventura.org/design-gallery
If current_language is blank I want to display a shortcode for the ‘Spanish’ version. If current_language = ‘es’ I want to display a shortcode for ‘Inglés’ to display the ‘English’ version. Thanks
Plugin Author
edo888
(@edo888)
Hi,
You can just use Language names widget look and also add this CSS code: a.gt-current-lang{display:none}
It will hide the current selected language. There is no point to use the Float look, since you only have 2 languages.
Thanks! 🙂
Thanks! I got something nice working:
https://staging.alanonventura.org