Amazon Translate
Developer Guide

TranslateText

Translates input text from the source language to the target language. You can translate between English (en) and one of the following languages, or between one of the following languages and English.

  • Arabic (ar)

  • Chinese (Simplified) (zh)

  • Chinese (Traditional) (zh-TW)

  • Czech (cs)

  • French (fr)

  • German (de)

  • Italian (it)

  • Japanese (ja)

  • Portuguese (pt)

  • Russian (ru)

  • Spanish (es)

  • 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", "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

One of the supported language codes for the source text. If the TargetLanguageCode is not "en", the SourceLanguageCode must be "en".

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

One of the supported language codes for the target text. If the SourceLanguageCode is not "en", the TargetLanguageCode must be "en".

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

Required: Yes

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.

Required: Yes

Response Syntax

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

SourceLanguageCode

The language code for the language of the input text.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

TargetLanguageCode

The language code for the language of the translated text.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 5.

TranslatedText

The text translated into the target language.

Type: String

Length Constraints: Minimum length of 1.

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 is invalid.

HTTP Status Code: 400

ServiceUnavailableException

Amazon Translate is unavailable. Retry your request later.

HTTP Status Code: 400

TextSizeLimitExceededException

The size of the input text exceeds the length constraint for the Text field. Try again with a shorter text.

HTTP Status Code: 400

TooManyRequestsException

The number of requests exceeds the limit. Resubmit your request later.

HTTP Status Code: 400

UnsupportedLanguagePairException

Amazon Translate cannot translate input text in the source language into this 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: