开发者

Google translate on my website

开发者 https://www.devze.com 2023-03-26 03:43 出处:网络
I\'m trying to embed Google Translate snippet in my website, but for some reason it is not even displayed.

I'm trying to embed Google Translate snippet in my website, but for some reason it is not even displayed. I go here: Google tools

Copy this:

<div id="google_translate_element"></div>
<script>
   function googleTranslateElementInit() {
      new google.translate.TranslateElement({
         pageLanguage: 'en'
      }, 'google_translate_element开发者_StackOverflow社区');
   }
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Paste it to my webpage. And I don't see it there.

What am I missing? Some HTML maybe?


Here is a working example. I think you are missing "&ug=section&hl={LANGUAGE}" parameters:

My Page Тестирование

<script>
function googleSectionalElementInit() {
  new google.translate.SectionalElement({
    sectionalNodeClassName: 'translate',
    controlNodeClassName: 'translate_control',
    background: '#f4fa58'
  }, 'google_sectional_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en"></script>

http://jsfiddle.net/maxim75/H3Wkr/ - working example


In the HTML, the 'control' class element needs to be nested in the 'section' element. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消