I've read this answer Modifying element from google.translate.TranslateElement results as well as others dealing with modifying the style and loading of the Google Translate translate element.
The difference with my usage is that I'm using layout: google.translate.TranslateElement.InlineLayout.VERTICAL instead of SIMPLE; all of the other answers deal with SIMPLE.
One issue I'm having is using .fadeIn on the google-translate div doesn't work. I still get a flash of text from .goog-logo-link and I see Select a Language before it changes to Translate.
That might have something to do with the myTimer function from Modifying element from google.translate.TranslateElement results . But myTimer the only way I figured out how to change the text of .goog-te-combo option:first from Select a Language to Translate.
So,
Is there a more efficient way to change the text of
.goog-te-combo option:firstfromSelect a LanguagetoTranslate?how can I get
.fadeInto work on thegoogle-translatediv so that changing the text fromSelect a LanguagetoTranslateand hiding.goog-logo-linkis hidden until the entire div is faded in?
jsfiddle: https://jsfiddle.net/gfzcjwmv/7/
<script>
$(window).on('load', function() {
$(".goog-logo-link").empty();
$('.goog-te-gadget').html($('.goog-te-gadget').children());
$("#google-translate").fadeIn('1000');
});
</script>
<div id="google-translate">
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en', includedLanguages: 'af,ach,ak,am,ar,az,be,bem,bg,bh,bn,br',
layout: google.translate.TranslateElement.InlineLayout.VERTICAL
}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
<script>
$(window).on('load', function() {
function cleartimer() {
setTimeout(function(){
window.clearInterval(myVar);
}, 1000);
}
function myTimer() {
if ($('.goog-te-combo option:first').length) {
$('.goog-te-combo option:first').html('Translate');
cleartimer();
}
}
var myVar = setInterval(function(){ myTimer() }, 300);
});
</script>
