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
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | |