如何在 chrome 中从 html 禁用谷歌翻译

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12238396/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:36:03  来源:igfitidea点击:

How to disable google translate from html in chrome

htmlgoogle-chromegoogle-translate

提问by twinlakes

I just made a website for a french restaurant. The website is in english, but I guess there is enough french on the website (labeled pictures of menu items) to prompt the visitor to translate the website if using Chrome.

我刚刚为一家法国餐厅制作了一个网站。该网站是英文的,但我想网站上有足够的法语(菜单项的标签图片)可以提示访问者在使用 Chrome 时翻译网站。

Is there something I can add to the html to prevent chrome from asking to translate the page? I'd assume it'd be something like <html lang="en">but that doesn't work.

有什么我可以添加到 html 以防止 chrome 要求翻译页面的内容吗?我认为它会是类似的东西,<html lang="en">但这不起作用。

Any ideas?

有任何想法吗?

Thanks

谢谢

回答by Matthew Adams

New Answer

新答案

Add translate="no"to your <html>tag, like so:

添加translate="no"到您的<html>标签,如下所示:

<html translate="no">

MDN Reference

MDN 参考



Old Answer

旧答案

(This should still work but is less desirable because it is Google-specific, and there are other translation services out there.)

(这应该仍然有效,但不太理想,因为它是特定于 Google 的,而且还有其他翻译服务。)

Add this tag in between <head>and </head>:

<head>和之间添加此标签</head>

<meta name="google" content="">

Documentation reference

文档参考

回答by edelans

The meta tag in the <head>didn't work for me, but

中的元标记<head>对我不起作用,但是

added to a parent div(or even <body>) did work and allows more precise control of the content you don't want to be translated.

添加到父级div(甚至<body>)确实有效,并允许更精确地控制您不想翻译的内容。

回答by ?brahim Sakac?

So for ultimate solution I made;

所以对于我提出的最终解决方案;

<html lang="en" translate="no">
<head><meta name="google" content="" /> </head>

This worked for me.

这对我有用。

回答by rkalways

Lets add this inide your <head> </head>

让我们在你的里面添加这个 <head> </head>

content=""for a meta name="google"

content=""为一个 meta name="google"

should work in your case.

应该适用于您的情况。

回答by BrainSlugs83

FYI, if you want something that will work for all content in your site (including that which is not HTML), you can set the Content-Languageheader in your response (source) to the appropriate language, (in my case, en-US).

仅供参考,如果您希望某些内容适用于您网站中的所有内容(包括非 HTML 的内容),您可以将Content-Language响应()中的标头设置为适当的语言(在我的情况下为en-US)。

This has the benefit here is that it will "disable" the offer to translate the page for you(because it will know the source language correctly), but for other, non-native readers, they will still have the option to translate your site into their own language, and it will work correctly.

这样做的好处这里是,它会“禁用”的报价页面的翻译(因为它会正确地知道源语言),但对于其他的,非本地的读者,他们仍然会体现你的网站的选项转换成他们自己的语言,它将正常工作。

(Also for my use case, where Chrome was offering to translate well formatted JSON from latin to English, that BS goes away.)

(对于我的用例,Chrome 提供将格式良好的 JSON 从拉丁语翻译成英语,BS 消失了。)

回答by OSMQuote

You can define the language on the HTML tag like

您可以在 HTML 标签上定义语言,如

<html lang="en">

to discourage Google Chrome to translate the page.

阻止谷歌浏览器翻译页面。