Exclude HTML tags when translating with Google Translate API

烈酒焚心 提交于 2019-12-21 14:36:15

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/33884381/exclude-html-tags-when-translating-with-google-translate-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!