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
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 | |