为什么 Chrome 会错误地确定页面使用不同的语言并提供翻译? [英] Why does Chrome incorrectly determine page is in a different language and offer to translate?

查看:54
本文介绍了为什么 Chrome 会错误地确定页面使用不同的语言并提供翻译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的 Google Chrome 自动翻译功能在我们的一个应用程序中的一页上出错.每当我们导航到这个特定页面时,Chrome 都会告诉我们该页面是丹麦语并提供翻译.该页面是英文的,就像我们应用程序中的所有其他页面一样.这个特定的页面是一个内部测试页面,有几十个带有英文标签的表单域.我不知道为什么 Chrome 认为这个页面是丹麦语.

有没有人了解此语言检测功能的工作原理以及我如何确定是什么导致 Chrome 认为该页面是丹麦语?

解决方案

更新:根据谷歌

<块引用>

我们不使用任何代码级别的语言信息,例如 lang属性.

他们建议您明确说明您网站的语言.尽管 Content-Language 已被弃用并且 Google 表示他们忽略了 lang

,但使用以下似乎有帮助的内容

<meta charset="UTF-8"><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="en">

如果这不起作用,您始终可以在隐藏的 div 中放置一堆文本(例如您的关于"页面).这也可能有助于 SEO.

编辑(和更多信息)

OP 正在询问 Chrome,因此 Google 的建议 贴在上面.对于其他浏览器,通常有三种方法可以实现这一点:

  1. W3C 推荐:在 html 标签中使用 lang 和/或 xml:lang 属性:

  2. 更新:以前是Google 推荐 现在已弃用的规范 尽管它可能仍然对 Chrome 有帮助.:meta http-equiv(如上所述):

  3. 使用 HTTP 标头(不推荐基于 跨浏览器识别测试):

    <块引用>

    HTTP/1.1 200 OK日期:2003 年 11 月 5 日,星期三 10:46:04 GMT内容类型:文本/html;字符集=iso-8859-1内容语言:en

完全退出 Chrome 并重新启动它以确保检测到更改.Chrome 并不总是在标签页刷新时选择新的元标记.

The new Google Chrome auto-translation feature is tripping up on one page within one of our applications. Whenever we navigate to this particular page, Chrome tells us the page is in Danish and offers to translate. The page is in English, just like every other page in our app. This particular page is an internal testing page that has a few dozen form fields with English labels. I have no idea why Chrome thinks this page is Danish.

Does anyone have insights into how this language detection feature works and how I can determine what is causing Chrome to think the page is in Danish?

解决方案

Update: according to Google

We don’t use any code-level language information such as lang attributes.

They recommend you make it obvious what your site's language is. Use the following which seems to help although Content-Language is deprecated and Google says they ignore lang

<html lang="en" xml:lang="en" xmlns= "http://www.w3.org/1999/xhtml">
<meta charset="UTF-8">
<meta name="google" content="notranslate">
<meta http-equiv="Content-Language" content="en">

If that doesn't work, you can always place a bunch of text (your "About" page for instance) in a hidden div. That might help with SEO as well.

EDIT (and more info)

The OP is asking about Chrome, so Google's recommendation is posted above. There are generally three ways to accomplish this for other browsers:

  1. W3C recommendation: Use the lang and/or xml:lang attributes in the html tag:

    <html lang="en" xml:lang="en" xmlns= "http://www.w3.org/1999/xhtml">
    

  2. UPDATE: previously a Google recommendation now deprecated spec although it may still help with Chrome. : meta http-equiv (as described above):

    <meta http-equiv="Content-Language" content="en">
    

  3. Use HTTP headers (not recommended based on cross-browser recognition tests):

    HTTP/1.1 200 OK
    Date: Wed, 05 Nov 2003 10:46:04 GMT
    Content-Type: text/html; charset=iso-8859-1
    Content-Language: en
    

Exit Chrome completely and restart it to ensure the change is detected. Chrome doesn't always pick up the new meta tag on tab refresh.

这篇关于为什么 Chrome 会错误地确定页面使用不同的语言并提供翻译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆