机器批量翻译,支持多段文本进行翻译

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String GetBatchTranslate

系统规定参数。取值:GetBatchTranslate。

ApiType String translate_standard
  • 版本类型,必须选择一个版本
  • 通用版本:translate_standard
  • 专业版本:translate_ecommerce
FormatType String text

翻译文本的格式,html( 网页格式。设置此参数将对待翻译文本以及翻译后文本按照html格式进行处理)、text(文本格式。设置此参数将对传入待翻译文本以及翻译后结果不做文本格式处理,统一按纯文本格式处理。

Scene String general
  • 专业版本支持的场景:商品标题(title),商品描述(description),商品沟通(communication),医疗(medical),社交(social)
  • 通用版本支持的场景:general
SourceLanguage String en

原文语言参考语言code

SourceText String {"11":"hello boy","12":"go home","13":"we can"}

json 数据格式

key:唯一的标记id,用于翻译结果拿到对应的id,对应上原文

value:待翻译的内容

具体格式如下:

说明 待翻译的条数不能超过100
说明 单条翻译字符数不能超过1000字符
{ "11": "hello boy", "12": "go home", "13": "we can" }
TargetLanguage String zh

译文语言参考语言code

返回数据

名称 类型 示例值 描述
Code Integer 200

错误码

Message String success

返回信息

RequestId String 86D18195-D89C-4C8C-9DC4-5FCE789CE6D5

请求的唯一id,用于后续排查问题使用

TranslatedList List [{"code":"200","wordCount":"9","index":"11","translated":"你好男孩"},{"code":"200","wordCount":"7","index":"12","translated":"回家"},{"code":"200","wordCount":"6","index":"13","translated":"我们可以"}]

返回结果,json格式

code:单条翻译的状态码

wordCount:原文的字符数

index:入参时候的key,唯一id,用于对应到原文

translated:翻译结果

[ { "code": "200", "wordCount": "9", "index": "11", "translated": "你好男孩" }, { "code": "200", "wordCount": "7", "index": "12", "translated": "回家" }, { "code": "200", "wordCount": "6", "index": "13", "translated": "我们可以" } ]

示例

请求示例

http(s)://[Endpoint]/?Action=GetBatchTranslate
&ApiType=translate_standard
&FormatType=text	
&Scene=general
&SourceLanguage=en
&SourceText={"11":"hello boy","12":"go home","13":"we can"}
&TargetLanguage=zh
&<公共请求参数>

正常返回示例

XML格式

<Message>success</Message>
<RequestId>86D18195-D89C-4C8C-9DC4-5FCE789CE6D5</RequestId>
<TranslatedList>[{"code":"200","wordCount":"9","index":"11","translated":"你好男孩"},{"code":"200","wordCount":"7","index":"12","translated":"回家"},{"code":"200","wordCount":"6","index":"13","translated":"我们可以"}]</TranslatedList>
<Code>200</Code>

JSON格式

{"Message":"success","RequestId":"86D18195-D89C-4C8C-9DC4-5FCE789CE6D5","TranslatedList":"[{\"code\":\"200\",\"wordCount\":\"9\",\"index\":\"11\",\"translated\":\"你好男孩\"},{\"code\":\"200\",\"wordCount\":\"7\",\"index\":\"12\",\"translated\":\"回家\"},{\"code\":\"200\",\"wordCount\":\"6\",\"index\":\"13\",\"translated\":\"我们可以\"}]","Code":"200"}

错误码

HttpCode 错误码 错误信息 描述
110 System.AccountNotActivated The account has not activated the service. 账号没有开通服务
113 System.AccountNotActivatedOrInArrears The service is not activated or the account has an outstanding balance. 账号服务没有开通或者欠费
102 System.Error A system error occurred. 系统错误
106 System.LanguageDetectError An error occurred while detecting the language. 语种识别错误
105 System.LanguageNotSupported The specified language pair is not supported. 该语向不支持
104 System.ParameterError Some required parameters are missing. 参数错误
101 System.RequestTimeOut The request has timed out. 请求超时
108 System.StringTooLong The maximum length of the specified string is exceeded. 字符过长
109 System.SubNotPermission The sub account is not authorized to perform the operation. 子账号没有权限
109 System.subNotPermission The sub-account is not authorized to perform the operation. 子账号没有权限
111 System.SubServiceFailed Sub-account service failed. 子账号服务失败
107 System.TranslateError An error occurred while translating. 翻译错误
112 System.TranslateServiceCallFailed Failed to call the translation service. 翻译服务调用失败
199 System.unknownError An unknown error occurred. 未知错误
199 System.UnknownError An unknown system error occurred. 未知错误
103 System.UrlDecodingError An error occurred while decoding the URL. Verify that the specified URL is encoded. URL编码错误

访问错误中心查看更多错误码。

访问错误中心查看更多错误码。