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

查看:82
本文介绍了使用 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.

之前阅读:临时从 Google Translate API 的字符串中删除 HTML 以降低成本

推荐答案

Google 有一个可选参数 format.

Google have a optional parameter format.

•此可选参数允许您指示要添加的文本翻译为纯文本或 HTML.html"的值表示HTML 和文本"值表示纯文本.

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

•默认:格式=html.

•Default: format=html.

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

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

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