Nida
Nida

Reputation: 1702

Google translation with flags should not get redirect to other page

I am using google's language picker with countries flags by using following code in template file in wordpress.

           <!-- Add English to Chinese (Simplified) BETA -->

           <a target="_blank" rel="nofollow" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en%7Czh-CN&hl=en&ie=UTF8'); return false;" title="Google-Translate-Chinese (Simplified) BETA"><img border="0" style="cursor:pointer; cursor:hand;" width="19" alt="Google-Translate-Chinese (Simplified) BETA" src="https://sites.google.com/site/translationflags/images/_chinese_s.png" height="19" title="Google-Translate-Chinese (Simplified) BETA"/></a>

           <!-- END English to Chinese (Simplified) BETA-->



         <!-- Add English to French -->

             <a target="_blank" rel="nofollow" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=en%7Cfr&hl=en&ie=UTF8'); return false;" title="Google-Translate-English to French "><img border="0" style="cursor:pointer; cursor:hand;" width="19" alt="Google-Translate-English to French " src="https://sites.google.com/site/translationflags/images/_french_s.png" height="19" title="Google-Translate-English to French "/></a>
             ...

             ...

When we click on flag in the webpage, it gets redirected to other page(google's translation page). And there the page gets translated to other language.But I want it shouldn't get redirected to other page instead it should translate on the same page like by using simple google translation code with dropdown option. Please help me!!!

Upvotes: 0

Views: 1871

Answers (1)

hemantrautela
hemantrautela

Reputation: 84

I think you just need : --

<div id="google_translate_element" style="float:left; padding-left:15px">
</div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en',  multilanguagePage: true,
layout: google.translate.TranslateElement.FloatPosition.BOTTOM_RIGHT},     'google_translate_element');
}
</script> 
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?    cb=googleTranslateElementInit"></script>

try this

Upvotes: 1

Related Questions