TranslateDocument
Translates the input document from the source language to the target language.
This synchronous operation supports text, HTML, or Word documents as the input document.
TranslateDocument
supports translations from English to any supported language,
and from any supported language to English. Therefore, specify either the source language code
or the target language code as “en” (English).
If you set the Formality
parameter, the request will fail if the target language does
not support formality. For a list of target languages that support formality, see
Setting formality
in the Amazon Translate Developer Guide.
Request Syntax
{
"Document": {
"Content": blob
,
"ContentType": "string
"
},
"Settings": {
"Brevity": "string
",
"Formality": "string
",
"Profanity": "string
"
},
"SourceLanguageCode": "string
",
"TargetLanguageCode": "string
",
"TerminologyNames": [ "string
" ]
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- Document
-
The content and content type for the document to be translated. The document size must not exceed 100 KB.
Type: Document object
Required: Yes
- Settings
-
Settings to configure your translation output. You can configure the following options:
-
Brevity: not supported.
-
Formality: sets the formality level of the output text.
-
Profanity: masks profane words and phrases in your translation output.
Type: TranslationSettings object
Required: No
-
- SourceLanguageCode
-
The language code for the language of the source text. For a list of supported language codes, see Supported languages in the Amazon Translate Developer Guide.
To have Amazon Translate determine the source language of your text, you can specify
auto
in theSourceLanguageCode
field. If you specifyauto
, Amazon Translate will call Amazon Comprehend to determine the source language.Note
If you specify
auto
, you must send theTranslateDocument
request in a region that supports Amazon Comprehend. Otherwise, the request returns an error indicating that autodetect is not supported.Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
Required: Yes
- TargetLanguageCode
-
The language code requested for the translated document. For a list of supported language codes, see Supported languages.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
Required: Yes
- TerminologyNames
-
The name of a terminology list file to add to the translation job. This file provides source terms and the desired translation for each term. A terminology list can contain a maximum of 256 terms. You can use one custom terminology resource in your translation request.
Use the ListTerminologies operation to get the available terminology lists.
For more information about custom terminology lists, see Custom terminology in the Amazon Translate Developer Guide.
Type: Array of strings
Length Constraints: Minimum length of 1. Maximum length of 256.
Pattern:
^([A-Za-z0-9-]_?)+$
Required: No
Response Syntax
{
"AppliedSettings": {
"Brevity": "string",
"Formality": "string",
"Profanity": "string"
},
"AppliedTerminologies": [
{
"Name": "string",
"Terms": [
{
"SourceText": "string",
"TargetText": "string"
}
]
}
],
"SourceLanguageCode": "string",
"TargetLanguageCode": "string",
"TranslatedDocument": {
"Content": blob
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- AppliedSettings
-
Settings to configure your translation output. You can configure the following options:
-
Brevity: reduces the length of the translation output for most translations. Available for
TranslateText
only. -
Formality: sets the formality level of the translation output.
-
Profanity: masks profane words and phrases in the translation output.
Type: TranslationSettings object
-
- AppliedTerminologies
-
The names of the custom terminologies applied to the input text by Amazon Translate to produce the translated text document.
Type: Array of AppliedTerminology objects
- SourceLanguageCode
-
The language code of the source document.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
- TargetLanguageCode
-
The language code of the translated document.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
- TranslatedDocument
-
The document containing the translated content. The document format matches the source document format.
Type: TranslatedDocument object
Errors
For information about the errors that are common to all actions, see Common Errors.
- InternalServerException
-
An internal server error occurred. Retry your request.
HTTP Status Code: 500
- InvalidRequestException
-
The request that you made is not valid. Check your request to determine why it's not valid and then retry the request.
HTTP Status Code: 400
- LimitExceededException
-
The specified limit has been exceeded. Review your request and retry it with a quantity below the stated limit.
HTTP Status Code: 400
- ResourceNotFoundException
-
The resource you are looking for has not been found. Review the resource you're looking for and see if a different resource will accomplish your needs before retrying the revised request.
HTTP Status Code: 400
- ServiceUnavailableException
-
The Amazon Translate service is temporarily unavailable. Wait a bit and then retry your request.
HTTP Status Code: 500
- TooManyRequestsException
-
You have made too many requests within a short period of time. Wait for a short time and then try your request again.
HTTP Status Code: 400
- UnsupportedLanguagePairException
-
Amazon Translate does not support translation from the language of the source text into the requested target language. For more information, see Supported languages in the Amazon Translate Developer Guide.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: