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

1、调用接口QPS限制50,如有扩展需求,请与我们联系 钉钉群号:21983957

2、字符长度上限是5000字符,若超出上限,可以保存成文件,使用文档翻译

3、请确保在使用该接口前,已充分了解通用版和专业版翻译产品的收费方式和价格

4、批量翻译接口参考阿里云OpenAPI开发者门户调试调用

调试

您可以在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
  • 专业版本支持的场景:商品标题(title),商品描述(description),商品沟通(communication),医疗(medical),社交(social)
  • 通用版本支持的场景:general
ApiType String translate_standard
  • 版本类型,必须选择一个版本
  • 通用版本:translate_standard
  • 专业版本:translate_ecommerce
SourceText String {"11":"hello boy","12":"go home","13":"we can"}

json 数据格式

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

value:待翻译的内容

具体格式如下:

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

返回数据

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

错误码

Message String success

返回信息

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

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

TranslatedList Array of Object [{"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格式

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 错误码 错误信息 描述
110 System.AccountNotActivated The account has not activated the service. 账号没有开通服务
199 System.unknownError An unknown error occurred. 未知错误
111 System.SubServiceFailed Sub-account service failed. 子账号服务失败
101 System.RequestTimeOut The request has timed out. 请求超时
112 System.TranslateServiceCallFailed Failed to call the translation service. 翻译服务调用失败
102 System.Error A system error occurred. 系统错误
113 System.AccountNotActivatedOrInArrears The service is not activated or the account has an outstanding balance. 账号服务没有开通或者欠费
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. 子账号没有权限

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