translate_text
async
¶
translate_text(
text: BoundedLengthString,
source_language_code: LanguageCodeString,
target_language_code: LanguageCodeString,
*,
config_overrides: Optional[AsyncTranslateClientConfig] = None,
terminology_names: Optional[ResourceNameList] = None,
settings: Optional[TranslationSettings] = None,
) -> TranslateTextResponse
Translates input text from the source language to the target language. For a list of available languages and language codes, see Supported languages.
Parameters:
-
text(BoundedLengthString) –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.
-
terminology_names(Optional[ResourceNameList], default:None) –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.
-
source_language_code(LanguageCodeString) –The language code for the language of the source text. For a list of language codes, see Supported languages.
To have Amazon Translate determine the source language of your text, you can specify
autoin theSourceLanguageCodefield. If you specifyauto, Amazon Translate will call Amazon Comprehend to determine the source language.If you specify
auto, you must send theTranslateTextrequest in a region that supports Amazon Comprehend. Otherwise, the request returns an error indicating that autodetect is not supported. -
target_language_code(LanguageCodeString) –The language code requested for the language of the target text. For a list of language codes, see Supported languages.
-
settings(Optional[TranslationSettings], default:None) –Settings to configure your translation output. You can configure the following options:
-
Brevity: reduces the length of the translated output for most translations.
-
Formality: sets the formality level of the output text.
-
Profanity: masks profane words and phrases in your translation output.
-
Raises:
-
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.
-
InternalServerException–An internal server error occurred. Retry your request.
-
InvalidRequestException–The request that you made is not valid. Check your request to determine why it's not valid and then retry the request.
-
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.
-
ServiceUnavailableException–The Amazon Translate service is temporarily unavailable. Wait a bit and then retry your request.
-
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.
-
TooManyRequestsException–You have made too many requests within a short period of time. Wait for a short time and then try your request again.
-
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.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_translate/_services/async_translate.py
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 | |