Machine batch translation, which supports multiple text segments for translation.
1. The QPS limit for calling the interface is 50. If you have any expansion requirements, please contact us DingTalk group number: 21983957
2. The maximum length of a single character in batch translation is 1000 characters, and a maximum of 50 characters can be translated at a time.Please ensure that you have fully understood the charging methods and prices of universal version and professional translation products before using this interface.
Debugging
Request parameters
| Parameter | Type | Required | Example | Message |
|---|---|---|---|---|
| Action | String | Yes | GetBatchTranslate | The operation that you want to perform. Set the value to GetBatchTranslate. |
| FormatType | String | Yes | text | The format of the translated text. html (web page format. Setting this parameter will process the text to be translated and the translated text in html format), text (text format. If you set this parameter, the text to be translated and the translated results will not be text format processed, but will be processed as pure text format. |
| TargetLanguage | String | Yes | zh | |
| SourceLanguage | String | Yes | en | |
| Scene | String | Yes | general |
|
| ApiType | String | Yes | translate_standard |
|
| SourceText | String | Yes | {"11":"hello boy","12":"go home","13":"we can"} | json data format Key: Unique tag id, used to get the corresponding id for the translation result, corresponding to the original text value: the content to be translated The following code shows the format of the event parameter: { "11": "hello boy", "12": "go home", "13": "we can"}Note The number of pieces to be translated cannot exceed 50 Note The number of characters in a single translation cannot exceed 1000 characters. Note key does not count the translated characters Note In the content to be translated, characters are included in punctuation, spaces, and html tags |
Response parameters
| Parameter | Type | Example | Message |
|---|---|---|---|
| Code | Integer | 200 | Error codes |
| Message | String | success | The message that is returned. |
| RequestId | String | 86D18195-D89C-4C8C-9DC4-5FCE789CE6D5 | The unique ID of the request, which is used for subsequent troubleshooting. |
| TranslatedList | Array of Object | [{"code":"200","wordCount":"9","detectedLanguage": "en","index":"11","translated":"Hello Boy"},{"code":"200","wordCount":"7","detectedLanguage": "en","index":"12","translated":"Go Home"},{"code":"200","wordCount":"6","detectedLanguage": "en","index":"13","translated":"We can"}] | The returned result is in the JSON format. Code: status code of a single translation wordCount: the number of characters in the original text. index: key when entering the parameter, unique id, used to correspond to the original text detectedLanguage: the source language code after language identification when the source language is passed into auto translated: the translation result. [ { "code": "200", "wordCount": "9", "detectedLanguage": "en","index": "11", "translated": "Hello boy" }, { "code": "200", "wordCount": "7","detectedLanguage": "en", "index": "12", "translated": "Go home" }, { "code": "200", "wordCount": "6","detectedLanguage": "en", "index": "13", "translated": "We can" }] |
Examples
Sample requests
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
&<Common request parameters>Sample success response
XML format
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":"Hello Boy"},{"code":"200","wordCount":"7","index":"12","translated":"Go Home"},{"code":"200","wordCount":"6","index":"13","translated":"We can"}]</TranslatedList>
<Code>200</Code>JSON format
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\":\" Hello boy \"},{\\" code\":\"200\",\"wordCount\":\"7\", "index" : "12", "translated" : "Go home" },{" code " : " 200 "," wordCount " : " 6 "," index " : " 13 "," translated " : " We can "}]",
"Code" : "200"
}Error codes
| HttpCode | Error code | Error message | Remarks |
|---|---|---|---|
| 110 | System.AccountNotActivated | The account has not activated the service. | The account does not activate the service. |
| 199 | System.unknownError | An unknown error occurred. | The error message returned because an unknown error has occurred. |
| 111 | System.SubServiceFailed | Sub-account service failed. | Sub-account service failure |
| 101 | System.RequestTimeOut | The request has timed out. | The request timed out. |
| 112 | System.TranslateServiceCallFailed | Failed to call the translation service. | Translation service call failed |
| 102 | System.Error | A system error occurred. | System error. |
| 113 | System.AccountNotActivatedOrInArrears | The service is not activated or the account has an outstanding balance. | The account service is not activated or the payment is overdue. |
| 103 | System.UrlDecodingError | An error occurred while decoding the URL. Verify that the specified URL is encoded. | URL encoding error |
| 104 | System.ParameterError | Some required parameters are missing. | The error message returned because a specified parameter is invalid. |
| 105 | System.LanguageNotSupported | The specified language pair is not supported. | This language is not supported. |
| 106 | System.LanguageDetectError | An error occurred while detecting the language. | Language recognition error |
| 107 | System.TranslateError | An error occurred while translating. | Translation error |
| 108 | System.StringTooLong | The maximum length of the specified string is exceeded. | characters too long |
| 109 | System.SubNotPermission | The sub account is not authorized to perform the operation. | The RAM user has no permissions. |
| 109 | System.subNotPermission | The sub-account is not authorized to perform the operation. | The RAM user has no permissions. |
For a list of error codes, see Service error codes.