机器批量翻译,支持多段文本进行翻译。
1、调用接口QPS限制50,如有扩展需求,请与我们联系钉钉群号:23369411
2、批量翻译单条字符长度上限是1000字符,一次最多可翻译50条,请确保在使用该接口前,已充分了解通用版和专业版翻译产品的收费方式和价格
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | GetBatchTranslate | 系统规定参数。取值:GetBatchTranslate。 |
FormatType | String | 是 | text | 翻译文本的格式,html( 网页格式。设置此参数将对待翻译文本以及翻译后文本按照html格式进行处理)、text(文本格式。设置此参数将对传入待翻译文本以及翻译后结果不做文本格式处理,统一按纯文本格式处理。 |
TargetLanguage | String | 是 | zh | 译文语言参考语言code |
SourceLanguage | String | 是 | en | 原文语言参考语言code |
Scene | String | 是 | general |
|
ApiType | String | 是 | translate_standard |
|
SourceText | String | 是 | {"11":"hello boy","12":"go home","13":"we can"} | json 数据格式 key:唯一的标记id,用于翻译结果拿到对应的id,对应上原文 value:待翻译的内容 具体格式如下:
{
"11": "hello boy",
"12": "go home",
"13": "we can"
}
说明 待翻译的条数不能超过50 说明 单条翻译字符数不能超过1000字符 说明 key不会计入翻译的字符 说明 待翻译的内容中,标点、空格、html标签均会计入字符 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
Code | Integer | 200 | 错误码 |
Message | String | success | 返回信息 |
RequestId | String | 86D18195-D89C-4C8C-9DC4-5FCE789CE6D5 | 请求的唯一id,用于后续排查问题使用 |
TranslatedList | Array of Object | [ { "code": "200", "wordCount": "9", "detectedLanguage": "en" "index": "11", "translated": "你好男孩" }, { "code": "200", "wordCount": "7", "detectedLanguage": "en" "index": "12", "translated": "回家" }, { "code": "200", "wordCount": "6", "detectedLanguage": "en" "index": "13", "translated": "我们可以" } ] | 返回结果,json格式 code:单条翻译的状态码 wordCount:原文的字符数 detectedLanguage:源语言传入auto时,语种识别后的源语言代码 index:入参时候的key,唯一id,用于对应到原文 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
格式
HTTP/1.1 200 OK
Content-Type:application/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
格式
HTTP/1.1 200 OK
Content-Type:application/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 | 错误码 | 错误信息 | 描述 |
---|---|---|---|
101 | System.RequestTimeOut | The request has timed out. | 请求超时 |
102 | System.Error | A system error occurred. | 系统错误 |
103 | System.UrlDecodingError | An error occurred while decoding the URL. Verify that the specified URL is encoded. | URL编码错误 |
104 | System.ParameterError | Some required parameters are missing. | 参数错误 |
105 | System.LanguageNotSupported | The specified language pair is not supported. | 该语向不支持 |
106 | System.LanguageDetectError | An error occurred while detecting the language. | 语种识别错误 |
107 | System.TranslateError | An error occurred while translating. | 翻译错误 |
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. | 子账号没有权限 |
110 | System.AccountNotActivated | The account has not activated the service. | 账号没有开通服务 |
111 | System.SubServiceFailed | Sub-account service failed. | 子账号服务失败 |
112 | System.TranslateServiceCallFailed | Failed to call the translation service. | 翻译服务调用失败 |
113 | System.AccountNotActivatedOrInArrears | The service is not activated or the account has an outstanding balance. | 账号服务没有开通或者欠费 |
199 | System.unknownError | An unknown error occurred. | 未知错误 |
访问错误中心查看更多错误码。