Exclude HTML tags when translating with Google Translate API

cweitat picture cweitat · Nov 24, 2015 · Viewed 9.5k times · Source

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

Answer

cweitat picture cweitat · Nov 24, 2015

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