使用Google Translate API进行翻译时,请排除HTML标签 [英] Exclude HTML tags when translating with Google Translate API

查看:735
本文介绍了使用Google Translate API进行翻译时,请排除HTML标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我知道<span class="e;notranslate"e;> </span>用于省略文本以在跨度之间进行翻译.

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

我正在寻找将带有HTML标记的内容发送到Translate API的方法,并让其返回而不转换标记.无论如何,在JSON返回翻译后的文本时,是否可以在翻译之前将标签省略掉并放回去?或者是否有任何语法可将Translate API排除在翻译HTML标签之外?

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?

在确定是使用JS还是Java之前,先做一些研究.

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

请先阅读以下内容:临时从字符串中删除HTML,以降低Google Translate API的成本

推荐答案

Google具有可选参数format.

Google have a optional parameter format.

•此可选参数使您可以指示文本为 翻译为纯文本或HTML.值"html"表示 HTML和值"text"表示纯文本.

•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.

•默认:format = html.

•Default: format=html.

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

这篇关于使用Google Translate API进行翻译时,请排除HTML标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆