问题
I am using the google translator in my website, I want to change the select language text in the drop down. Anyone suggest for this. Here is my code;
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'ar', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
Thanks in advance.
回答1:
According to this question you can modify the element as you want.
Like this:
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
layout: google.translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script>
$(document).ready(function(){
$('#google_translate_element').bind('DOMNodeInserted', function(event) {
$('.goog-te-menu-value span:first').html('Translate');
$('.goog-te-menu-frame.skiptranslate').load(function(){
setTimeout(function(){
$('.goog-te-menu-frame.skiptranslate').contents().find('.goog-te-menu2-item-selected .text').html('Translate');
}, 100);
});
});
});
</script>
http://output.jsbin.com/jucoba
来源:https://stackoverflow.com/questions/36281876/how-to-change-google-translator-select-language-text-in-coding