Skip to content

Instantly share code, notes, and snippets.

@tedw
Created March 11, 2021 20:50
Show Gist options
  • Save tedw/fac000d3561ac2bb1f52a74fb2af5ead to your computer and use it in GitHub Desktop.
Save tedw/fac000d3561ac2bb1f52a74fb2af5ead to your computer and use it in GitHub Desktop.
Google Translate widget
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
var translateEl= new google.translate.TranslateElement({
includedLanguages: 'en,es',
pageLanguage: 'en'
// autoDisplay: false,// doesn’t seem to have any effect
// multilanguagePage: true// will always include the page language as an option
// NOTE: Setting the layout option will replace the <select> with inaccessible markup
// layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
// layout: google.translate.TranslateElement.FloatPosition.TOP_RIGHT// seems to be the same as SIMPLE
}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@dandeancook
Copy link

👍

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