Why does Chrome incorrectly determine page is in a different language and offer to translate?

Samuel Neff picture Samuel Neff · Mar 18, 2010 · Viewed 75.4k times · Source

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?

Answer

Kyle picture Kyle · Jun 28, 2010

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.