Skip to content

Instantly share code, notes, and snippets.

@carolineschnapp
Created February 1, 2011 19:27
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save carolineschnapp/806456 to your computer and use it in GitHub Desktop.
Save carolineschnapp/806456 to your computer and use it in GitHub Desktop.
Google Translate Embed Code
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script>
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@ndsda
Copy link

ndsda commented Jul 25, 2023

It does not work for me any more. It worked on my website since 2015 until this week. Has Google stopped supporting it?

Update: It started working again the next day - so just temporary downtime from Google.

@MickDawdy
Copy link

MickDawdy commented Jul 26, 2023 via email

@dabugen
Copy link

dabugen commented Sep 28, 2023

Using:

<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>

...works just fine for me as of today (setup on a new website).

@ndsda
Copy link

ndsda commented Sep 28, 2023

Yes, it now works for me too. I meant to write back to say it started working the following day. So there must have simply been a tempory issue in July.

@fyndeal
Copy link

fyndeal commented Mar 22, 2024

It is working for me (I build sites on a 3rd party platform) but the default menu language is coming up in the geographical local language (in this case Thai).
I tried a Google "expert" who insisted that the menu language is decided by your Chrome language settings, but he was full of crap. I have no Thai settings in my browser, or on my laptop at all. It's not even an alternative language choice in Windows or Office for me.
I insist that it's being decided by location but he disagreed.
To check, I set the following code in my website:

<script type="text/javascript">// </script> <script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" type="text/javascript"></script>

.. and it comes up as Thai (as I am in Thailand).
When I was last working in Zambia, it came up in English
To verify, I connected via a VPN to a server in London and, lo and behold, the menu language changed to English! I simultaneously checked the exact same website on my phone (not connected via VPN) and it's still in Thai.
Anyone know how to lock the menu language to English (or another language, come to that)?
Thanks peeps.

sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment