Issue with Google Translation on Website?
Asked Answered
B

1

4

So I am using the google translate tool for my website- I am setting it up via: https://translate.google.com/manager/website

Under display mode, I keep choosing automatic but it looks like the banner ALWAYS displays even though they state it will ONLY show if the browser is not the language of the site (which is EN)

What's going on? Is their tool broken? is there a way to use this tool to just show if the language is not en?

Blemish answered 11/9, 2014 at 16:47 Comment(3)
What is the URL of the site you are seeing this up on?Wilson
I can't give out the URL of the site- but I am copying the code google provides exactly as it listed it- <div id="google_translate_element"></div> <script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT}, 'google_translate_element'); } </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>Blemish
@user3267847: I suggest you to add that code to the question, also, add google-translate tag.Priggery
A
3

These things worked for me.

Paste the code below on your website. Languages mentioned in includedLanguages in googleTranslateElementInit() will display on your website.

I will suggest you to paste this in website header or footer section so that translation feature will yield on every page of your website.

<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'en,fr,es,it,de'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Also if you are looking for auto translate in specific language then add this piece of code as well.

<script>
(function() {
if(!window.location.hash) {
    window.location = window.location + '#googtrans(en|fr)';
    window.location.reload();
} 
})();   
</script>
Assiduous answered 30/5, 2017 at 10:44 Comment(2)
Still works in 2021, and clients still ask for it.Cornhusk
@Cornhusk glad, it helped.Assiduous

© 2022 - 2024 — McMap. All rights reserved.