Removing the Chrome "do you want to translate" popup

I have pages in a different language and don’t want English readers to see the google message popup “do you want to translate this page”

I have seen some classes or tags to add but was wondering what the best way would be in Pro. Is there some js I could put in my page through the builder?

thanks

Hi there,

You might want to try adding the code in the Global JS if you have Javascript codes to place on your site. X > Theme Options > JS:

Hope this helps.

I don’t actually have any js to do that, do you?
All I found was this to put in the header.

Hi,

Sorry for the confusion.

To prevent the pop up from showing, you can add the code below in your child theme’s functions.php file.

add_action( 'wp_head', 'prevent_translate_popup' );
function prevent_translate_popup(){
     if(is_page(1)) {  ?>
    <meta name="google" content="notranslate">
   <?php
     }
}

Change 1 with the page id of the page with a different language.

Here is our guide in getting the page id

Additional Info: https://support.google.com/webmasters/answer/79812

Hope that helps

that worked, thank you
could you also provide the code for multiple (more than 2) pages?

Hi @clefler,

You can enhance that existing code to implement multiple condition, like this

add_action( 'wp_head', 'prevent_translate_popup' );
function prevent_translate_popup(){
     if( is_page(1) || is_page(5) || is_page(98) ) {  ?>
    <meta name="google" content="notranslate">
   <?php
     }
}

The key part is is_page() and || in between, then just add the ID of your target page.

Hope this helps.

worked, thank you

You are most welcome @clefler!!

By the way, without adding any code, you can turn it off right in your Chrome browser.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.