18

我在我的网站中使用了谷歌翻译作为语言转换器,但它显示了令人讨厌的工具提示,称为“原始文本”。如何禁用此功能以及任何其他更好的想法/工具/api来执行此操作?

谢谢。使用的代码是...

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

5 回答 5

42

只需将此 CSS 添加到 CSS 文件的顶部:

.goog-tooltip {
    display: none !important;
}
.goog-tooltip:hover {
    display: none !important;
}
.goog-text-highlight {
    background-color: transparent !important;
    border: none !important; 
    box-shadow: none !important;
}

我浪费了 8 个小时来解决这个问题,但现在在这 3 行 CSS 之后,它看起来很棒 :-) 你可以在这里看到它的实际效果:SEOgenie - 自动化 SEO

于 2011-12-16T08:07:27.860 回答
8

There are some things you can do to "override" the Google translator display on your website.

I have been using the fallowing

To hide the suggestion box (the !important part is really important :) )

#goog-gt-tt, .goog-te-balloon-frame{display: none !important;} 
.goog-text-highlight { background: none !important; box-shadow: none !important;}

To hide the powered by

.goog-logo-link{display: none !important;}
.goog-te-gadget{height: 28px !important;  overflow: hidden;}

To remove the top frame

body{ top: 0 !important;}
.goog-te-banner-frame{display: none !important;}

Thera are some more, but i guess the above will drive you to the right path ;)

Regards to all.

于 2013-05-22T09:01:00.730 回答
1

我觉得我的方法更好^^

    $(document).ready(function() 
    {       
        translationTooltipsDisable();
    });


    function translationTooltipsDisable()
    {       
        //Override google's functions
        _tipon = function()  { /*Don't display the tooltip*/ };
        _tipoff = function() { /*Don't hide the tooltip*/ };
    }
于 2012-02-07T13:30:29.760 回答
1
#google_translate_element {
  display:none;
}

CSS display:none 可能会起作用。

于 2010-07-13T21:01:26.390 回答
0

看来您可以在他们用来执行“工具提示”的 iframe 上使用一些 CSS 将其隐藏。

.goog-te-balloon-frame { display: none; }

当他们更新服务并更改名称/结构时,它可能是一个移动的目标,但它现在可以在我正在进行的站点上运行。

更新:我注意到鼠标悬停/悬停背景颜色效果似乎与此方法有关,但它似乎是通过 JavaScript 完成的(添加为元素本身的样式属性,而不是可以更轻松地覆盖它的类切换)。使用 Google 的翻译 JavaScript 来做很多事情已经证明是相当困难的。无论如何,摆脱 iframe 是最重要的部分。

于 2011-06-09T18:34:49.367 回答