However, I have incorporated Google Reviews into my my Testimonials page, using a Widget from Elfsight. works brilliantly, BUT the base language is Spanish.
Is there any HTML code I can insert in the page head to force the page to be translated to English on page load, without user clicking the Google translate option on their browser?
I have found the following code on StackOverflow:
Code: Select all
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'es',
includedLanguages: 'es,en',
}, 'google_translate_element');
setTimeout(function() {
// Set the default language to English
var selectElement = document.querySelector('#google_translate_element select');
selectElement.value = 'en';
selectElement.dispatchEvent(new Event('change'));
}, 1000);
}
</script>