GetBatchTranslate - 机器批量翻译调用指南

更新时间:
复制 MD 格式

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

接口说明

1、调用接口 QPS 限制 50,如有扩展需求,请与我们联系钉钉群号:23369411 2、批量翻译单条字符长度上限是 1000 字符,一次最多可翻译 50 条,若超出上限,可以保存成文件,使用文档翻译 3、请确保在使用该接口前,已充分了解通用版和专业版翻译产品的收费方式和价格 4、批量翻译接口参考阿里云 OpenAPI 开发者门户调试调用

调试

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

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

alimt:GetBatchTranslate

get

*全部资源

*

无 无

请求参数

名称

类型

必填

描述

示例值

FormatType

string

是

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

text

TargetLanguage

string

是

译文语言参考语言 code

zh

SourceLanguage

string

是

原文语言参考语言 code

en

Scene

string

是

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

  • 通用版本支持的场景:general

general

ApiType

string

是

  • 版本类型,必须选择一个版本

  • 通用版本:translate_standard

  • 专业版本:translate_ecommerce

translate_standard

SourceText

string

是

json 数据格式

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

value:待翻译的内容

具体格式如下: { "11": "hello boy", "12": "go home", "13": "we can" }

说明

待翻译的条数不能超过 50 单条翻译字符数不能超过 1000 字符 总字符数不能超过 8000 字符 key 不会计入翻译的字符 待翻译的内容中,标点、空格、html 标签均会计入字符

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

返回参数

名称

类型

描述

示例值

object

Code

integer

错误码

200

Message

string

返回信息

success

RequestId

string

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

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

TranslatedList

array<object>

批量翻译结果列表。

[{"code":"200","wordCount":"9","detectedLanguage":"en","index":"11","translated":"你好男孩"}]

object

返回结果,json 格式

code:单条翻译的状态码

wordCount:原文的字符数

detectedLanguage:源语言传入 auto 时,语种识别后的源语言代码

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

translated:翻译结果

[ { "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": 200,
  "Message": "success",
  "RequestId": "86D18195-D89C-4C8C-9DC4-5FCE789CE6D5",
  "TranslatedList": [
    {
      "test": "test",
      "test2": 1
    }
  ]
}

错误码

HTTP status code

错误码

错误信息

描述

110 System.AccountNotActivated The account has not activated the service.
111 System.SubServiceFailed Sub-account service failed.
199 System.unknownError An unknown error occurred.
199 System.UnknownError An unknown system error occurred.
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.
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.

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

变更历史

更多信息,参考变更详情。