TranslateText
Translates input text from the source language to the target language. For a list of available languages and language codes, see Supported languages.
Request Syntax
{
"Settings": {
"Formality": "string
",
"Profanity": "string
"
},
"SourceLanguageCode": "string
",
"TargetLanguageCode": "string
",
"TerminologyNames": [ "string
" ],
"Text": "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.
- Settings
-
Settings to configure your translation output, including the option to set the formality level of the output text and the option to mask profane words and phrases.
Type: TranslationSettings object
Required: No
- SourceLanguageCode
-
The language code for the language of the source text. The language must be a language supported by Amazon Translate. For a list of language codes, see Supported languages.
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 theTranslateText
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 language of the target text. The language must be a language supported by Amazon Translate.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
Required: Yes
- TerminologyNames
-
The name of the terminology list file to be used in the TranslateText request. You can use 1 terminology list at most in a
TranslateText
request. Terminology lists can contain a maximum of 256 terms.Type: Array of strings
Length Constraints: Minimum length of 1. Maximum length of 256.
Pattern:
^([A-Za-z0-9-]_?)+$
Required: No
- Text
-
The text to translate. The text string can be a maximum of 10,000 bytes long. Depending on your character set, this may be fewer than 10,000 characters.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 10000.
Pattern:
[\P{M}\p{M}]{1,10000}
Required: Yes
Response Syntax
{
"AppliedSettings": {
"Formality": "string",
"Profanity": "string"
},
"AppliedTerminologies": [
{
"Name": "string",
"Terms": [
{
"SourceText": "string",
"TargetText": "string"
}
]
}
],
"SourceLanguageCode": "string",
"TargetLanguageCode": "string",
"TranslatedText": "string"
}
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 that configure the translation output.
Type: TranslationSettings object
- AppliedTerminologies
-
The names of the custom terminologies applied to the input text by Amazon Translate for the translated text response.
Type: Array of AppliedTerminology objects
- SourceLanguageCode
-
The language code for the language of the source text.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
- TargetLanguageCode
-
The language code for the language of the target text.
Type: String
Length Constraints: Minimum length of 2. Maximum length of 5.
- TranslatedText
-
The translated text.
Type: String
Length Constraints: Maximum length of 20000.
Pattern:
[\P{M}\p{M}]{0,20000}
Errors
For information about the errors that are common to all actions, see Common Errors.
- DetectedLanguageLowConfidenceException
-
The confidence that Amazon Comprehend accurately detected the source language is low. If a low confidence level is acceptable for your application, you can use the language in the exception to call Amazon Translate again. For more information, see the DetectDominantLanguage operation in the Amazon Comprehend Developer Guide.
HTTP Status Code: 400
- 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
- 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
- TextSizeLimitExceededException
-
The size of the text you submitted exceeds the size limit. Reduce the size of the text or use a smaller document and then retry your request.
HTTP Status Code: 400
- 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 Error messages.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: