translate_document
¶
translate_document(
document: Document,
source_language_code: LanguageCodeString,
target_language_code: LanguageCodeString,
*,
config_overrides: Optional[TranslateClientConfig] = None,
terminology_names: Optional[ResourceNameList] = None,
settings: Optional[TranslationSettings] = None,
) -> TranslateDocumentResponse
Translates the input document from the source language to the target language. This synchronous operation supports text, HTML, or Word documents as the input document. TranslateDocument supports translations from English to any supported language, and from any supported language to English. Therefore, specify either the source language code or the target language code as “en” (English).
If you set the Formality parameter, the request will fail if the target language does not support formality. For a list of target languages that support formality, see Setting formality.
Parameters:
-
document(Document) –The content and content type for the document to be translated. The document size must not exceed 100 KB.
-
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 supported 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 theTranslateDocumentrequest 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 translated document. For a list of supported language codes, see Supported languages.
-
settings(Optional[TranslationSettings], default:None) –Settings to configure your translation output. You can configure the following options:
-
Brevity: not supported.
-
Formality: sets the formality level of the output text.
-
Profanity: masks profane words and phrases in your translation output.
-
Raises:
-
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.
-
LimitExceededException–The specified limit has been exceeded. Review your request and retry it with a quantity below the stated limit.
-
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.
-
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/translate.py
1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 | |