How do I tell Cloud Translation API to NOT translate something?

How do I tell Cloud Translation API to NOT translate something?

 

You can use the following HTML tags:

<span translate="no"> </span>

<span class="notranslate"> </span>

This functionality requires the source text to be submitted in HTML.

Why was a style attribute added to the translated text with text-align and direction CSS properties?

This occurs when you include HTML with the requested text to be translated, and you are translating from a right-to-left to a left-to-right language, or from a left-to-right to a right-to-left language. The translation includes the HTML style attribute with the text-align and direction CSS properties to ensure that the translated text is oriented in the proper direction. For example, translating

<h2>Sample text</h2>

from English to Hebrew returns the following JSON:

{
  "data": {
    "translations": [
      {
        "translatedText": "\u003ch2 style=\";text-align:right;direction:rtl\"\u003e טקסט לדוגמה (דברים) \u003c/h2\u003e"
      }
    ]
  }
}

 

According to Google instructions, setting class=”notranslate” prevents Google translation. This appears to work, though using it inline (e.g., for a single word) may imply some confusion, so you need to check out what happens.

For example,

Welcome to the <span class="notranslate">Cool</span> company website!

translates into Spanish as “Bienvenido a la Coolweb de la compañía!”, which isn’t that cool, though it demonstrates that “Cool” has been taken as a proper name; without the markup, the text would translate as “Bienvenido a la fresca web de la empresa!”.

Reformulating the text as

Welcome to the website of <span class="notranslate">Cool</span>!

 

SOURCE: https://cloud.google.com/translate/faq#technical

How to Stop Date Picker Date change while using Google Translator

Stop Date Picker Date change while using Google Translator

 

In the Website, when  changing the language from English to other Language like swedish, chinese or any other language, the Date picker value is changing & showing like NaN/NaN/NaN.

But, the Datepicker format is mm/dd/yyyy

Solution:

For, these we have to find the Date picker container where date i showing. Then find the below classes added in that container,

ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all

Then Add a new class with them, “notranslate”

ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all notranslate

If Google find this class in the container, Google will not translate the content of the container.

keyword “notranslate” will prevent your calendar to translate.

We, can add class using this function, like

$(function() {
    $(".datepicker").datepicker();
    $('.ui-datepicker').addClass('notranslate');
});

 

If you like our post, Please Comment & share.