How to disable google translate from html in chrome

前端 未结 6 1948
星月不相逢
星月不相逢 2020-11-27 11:32

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 v

相关标签:
6条回答
  • 2020-11-27 11:32

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

    class="notranslate"

    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.

    0 讨论(0)
  • 2020-11-27 11:34

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

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

    should work in your case.

    0 讨论(0)
  • 2020-11-27 11:36

    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-Language header in your response (source) to the appropriate language, (in my case, 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.)

    0 讨论(0)
  • 2020-11-27 11:44

    So for ultimate solution I made;

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

    This worked for me.

    0 讨论(0)
  • 2020-11-27 11:45

    New Answer

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

    <html translate="no">
    

    MDN Reference


    Old Answer

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

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

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

    Documentation reference

    0 讨论(0)
  • 2020-11-27 11:48

    To always work in any translator, copy and paste the code above:

    <html lang="en" class="notranslate" translate="no">    <!-- All translators -->
     <head><meta name="google" content="notranslate" /> <!-- Just for google -->
    </head>                                                <!-- Close head      -->
    

    The more simple wai is just adding the translate="no" proprety. This can be made in divs, text and more. Here's an example:

    // Just for instructions
    // Do not copy or paste
    console.log("The first div don't alows translateing. But the second, alows it.")
    console.log("Open the translator and see the efect.")
    DIV1
    <div translate="no">
    Try translating me!
    <b>Olá - Hello - Hola</b>
    </div>
    <hr>
    DIV2
    <div translate="yes">
    Now, you can do it!
    <b>Olá - Hello - Hola</b>
    </div>

    0 讨论(0)
提交回复
热议问题