'Google Translate not showing Language Options
I have put Google translate code on my site, but it's not showing Language option in select field:
And the code is:
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout:
google.translate.TranslateElement.InlineLayout.HORIZONTAL, autoDisplay: false},
'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
Solution 1:[1]
Re : google.Translate.ElementInit() callback .. autoDisplay: True or deleted should render the language options. Note that the option (language trigger value and name) are not rendered immediately after the this callback .. which is irritating if you want to switch language on a navigator.language || navigator.userLanguage result.
Solution 2:[2]
Here's the code i use:
<div id="google_translate_element"></div>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
autoDisplay:true,
defaultLanguage: 'en',
}, 'google_translate_element');
}
</script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ImageWare |
Solution 2 | Cletus Kingdom |