Great News! Try our new tool to convert img to amp-img. Try Now!

Monday, February 11, 2019

Disable Google Translate from Translating Specific Element

How to Disable Google Translate from Translating Specific Words or Content Blocks with JavaScript

How to Disable Google Translate from Translating Specific Web Element or Content

Google Translate is a Google application that allows Internet users to translate text into different languages. Google translate is certainly very useful for those who want to know the meaning of a writing that they don't understand, because of different languages.

Google Translate is usually also used by Internet users to translate content that is on a website to make it more understandable.

But usually for certain content, Webmaster don't want the content to be translated because it will change different intentions.

For example, a blog with website creation blogging content that usually contains a lot of HTML Script content. If visitors translate the page, all content will automatically be translate including HTML Code.

But there are several ways that can be done to prevent Google Translate translating our web pages. There are several ways that I will explain.

Prevent Google from Translating All Content

To prevent Google Translate from translating all content on the Website, you simply add the meta tag to <head>

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

The Meta tag will automatically notify Google Translate not to translate all the content on our website pages. 

Prevent Google Translate from translating certain content

If you only want to tell Google Translate not to translate certain content, then you can simply add the class='notranslate' attribute to the content. The attribute will tell and prevent Google Translate from translating the text that you have added the attribute to. 


If you write it with the following code:

Hello World, <span class='notranslate'>My Name</span> is Jane Doe

then what Google will translate into Bahasa Indonesia will be:

Halo Dunia, My Name adalah Jane Doe

Well, usually if you don't use this attribute in the <pre> tag, then if someone tries to use Google Translate on that webpage, the content that is in the <pre> tag will also be translate unless the code is followed by the <code> tag .

Hopefully useful :)