Created
March 11, 2021 20:50
-
-
Save tedw/fac000d3561ac2bb1f52a74fb2af5ead to your computer and use it in GitHub Desktop.
Google Translate widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
the pageLanguage is 'en', but the translate button itself is following the language of country by IP; how to fix this?
@dandeancook pageLanguage
defines the original language of the page, not the user’s preferred language.
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://developers.google.com/search/blog/2020/05/google-translates-website-translator