Amazon Translate
Developer Guide

TranslateText

Translates input text from the source language to the target language. It is not necessary to use English (en) as either the source or the target language but not all language combinations are supported by Amazon Translate. For more information, see Supported Language Pairs.

  • Arabic (ar)

  • Chinese (Simplified) (zh)

  • Chinese (Traditional) (zh-TW)

  • Czech (cs)

  • Danish (da)

  • Dutch (nl)

  • English (en)

  • Finnish (fi)

  • French (fr)

  • German (de)

  • Hebrew (he)

  • Indonesian (id)

  • Italian (it)

  • Japanese (ja)

  • Korean (ko)

  • Polish (pl)

  • Portuguese (pt)

  • Russian (ru)

  • Spanish (es)

  • Swedish (sv)

  • Turkish (tr)

To have Amazon Translate determine the source language of your text, you can specify auto in the SourceLanguageCode field. If you specify auto, Amazon Translate will call Amazon Comprehend to determine the source language.

Request Syntax

{ "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.

SourceLanguageCode

The language code for the language of the source text. The language must be a language supported by Amazon Translate.

To have Amazon Translate determine the source language of your text, you can specify auto in the SourceLanguageCode field. If you specify auto, Amazon Translate will call Amazon Comprehend to determine the source language.

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 TerminologyNames list that is taken as input to the TranslateText request. This has a minimum length of 0 and a maximum length of 1.

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 5,000 bytes long. Depending on your character set, this may be fewer than 5,000 characters.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 5000.

Pattern: [\P{M}\p{M}]{1,5000}

Required: Yes

Response Syntax

{ "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.

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 the translated text. The maximum length of this text is 5kb.

Type: String

Length Constraints: Maximum length of 10000.

Pattern: [\P{M}\p{M}]{0,10000}

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 invalid. Check your request to determine why it's invalid 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. Please wait a bit and then retry your request.

HTTP Status Code: 400

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 Exception Handling.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: