Make Google Translate widget ignore speсific elements

If you are using Google Translate integration feature, then you might want to disallow it translating certain elements.

By default, Google Translate widget won't translate any elements that have "notranslate" class. It also won't translate the Code Blocks. But if there is an element you can't assign a class to, you will need is a simple script that will do that for you.

What the script does is search for all elements with a specified class and adds the "notranslate" class to each of these elements.

How to implement

  • Open Topic Master Page settings section - either in the Portal Settings or the Project Settings, depending on the scale you want to apply this to.
  • Add the following HTML markup with the script into the Topic footer HTML.
  • If you have any publications, you might want to republish them to see the change

JavaScript Code

HTML
<script>
var allElementsOfOneClass = _$$(".Element_Class");
for (var i = 0; i < allElementsOfOneClass.length; i++)
{
CssHandler.addElClass(allElementsOfOneClass[i], "notranslate");
}
</script>