我的网站上有谷歌翻译

发布于 2024-11-28 00:41:55 字数 586 浏览 2 评论 0原文

我试图在我的网站中嵌入谷歌翻译片段,但由于某种原因它甚至没有显示。 我去这里: Google 工具

复制此内容:

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

将其粘贴到我的网页。 我在那里没有看到它。

我缺少什么? 也许是一些 HTML?

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');
   }
</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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回忆那么伤 2024-12-05 00:41:55

这是一个工作示例。我认为您缺少“&ug=section&hl={LANGUAGE}”参数:

我的页面

特克斯蒂罗夫涅

<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/ - 工作示例

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

如梦亦如幻 2024-12-05 00:41:55

在 HTML 中,“control”类元素需要嵌套在“section”元素中。 :)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文