admin管理员组文章数量:1334342
How can I modify this code to translate the only one container on page with id #lyrics?
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'ru', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, 'google_translate_element');
}
</script>
How can I modify this code to translate the only one container on page with id #lyrics?
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'ru', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, 'google_translate_element');
}
</script>
Share
Improve this question
edited Jul 27, 2014 at 17:14
Kartikeya Khosla
18.9k8 gold badges45 silver badges70 bronze badges
asked Jul 27, 2014 at 17:06
Jason ColeJason Cole
511 silver badge10 bronze badges
3
- ok, I'm replace 'google_translate_element' to 'lyrics', but I have the same result – Jason Cole Commented Jul 27, 2014 at 17:17
- Sorry. Take a look at this answer. – Halvor Holsten Strand Commented Jul 27, 2014 at 17:22
- I've seen this answer, but I can't apply this to my code, can you help me with this? – Jason Cole Commented Jul 27, 2014 at 17:25
2 Answers
Reset to default 6you can add class call notranslate into the body or the meta tag of the class then add the class translate into the div whom you want to translate its poor approach but it sure do you wok e.g
<body class="notranslate">
<h1>no translate paragraph</h1>
<h1 class="translate"> i want to translate the line</h1>
</body>
Solved with this function:
function googleSectionalElementInit() {
new google.translate.SectionalElement({
sectionalNodeClassName: 'lyrics',
controlNodeClassName: 'translate-lyrics',
background: 'trasparent'
}, 'google_sectional_element');
}
本文标签: javascriptGoogle API translator How can I translate only one DIVStack Overflow
版权声明:本文标题:javascript - Google API translator. How can I translate only one DIV? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742369086a2461870.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论