Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude HTML tags when translating with Google Translate API

Currently I know that <span class="e;notranslate"e;> </span> is used to omit out text to translate between the span.

I am looking out for sending content with HTML tag to Translate API and let it return without translating the tags. Is there anyway that tags could be omitted out before translating and putting them back when the JSON returns with the translated text or is there any syntax to exclude Translate API from translating the HTML tags?

Doing some research before I decide to whether code in JS or Java.

Read this before : Temporary removal of HTML from string for Google Translate API to reduce cost

like image 794
cweitat Avatar asked Nov 24 '15 02:11

cweitat


People also ask

How do I stop HTML translation?

However, if you don't want a section of your webpage to be translated, just add "class=notranslate" to any HTML element to prevent that element from being translated.

How do you exclude words in Google Translate?

Put a minus sign before words you want to exclude from your search results.


1 Answers

Google have a optional parameter format.

•This optional parameter allows you to indicate that the text to be translated is either plain-text or HTML. A value of "html" indicates HTML and a value of "text" indicates plain-text.

•Default: format=html.

https://cloud.google.com/translate/v2/using_rest

like image 138
cweitat Avatar answered Oct 09 '22 17:10

cweitat