You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with open(f".{file.split('.')[0]}.html", "rb") as in_file, open(interm_path, "wb") as out_file:
translator.translate_document(
in_file,
out_file,
target_lang="ZH",
formality="more"
)
it fails with
---------------------------------------------------------------------------
DeepLException Traceback (most recent call last)
Cell In[8], line 2
1 with open(f".{file.split('.')[0]}.html", "rb") as in_file, open(interm_path, "wb") as out_file:
----> 2 translator.translate_document(
3 in_file,
4 out_file,
5 target_lang="ZH",
6 formality="more"
7 )
File ~\anaconda3\Lib\site-packages\deepl\translator.py:604, in Translator.translate_document(self, input_document, output_document, source_lang, target_lang, formality, glossary, filename, output_format)
565 def translate_document(
566 self,
567 input_document: Union[TextIO, BinaryIO, Any],
(...)
575 output_format: Optional[str] = None,
576 ) -> DocumentStatus:
577 """Upload document, translate it into the target language, and download
578 result.
579
(...)
601 translation, the exception includes the document handle.
602 """
--> 604 handle = self.translate_document_upload(
605 input_document,
606 target_lang=target_lang,
607 source_lang=source_lang,
608 formality=formality,
609 glossary=glossary,
610 filename=filename,
611 output_format=output_format,
612 )
614 try:
615 status = self.translate_document_wait_until_done(handle)
File ~\anaconda3\Lib\site-packages\deepl\translator.py:680, in Translator.translate_document_upload(self, input_document, source_lang, target_lang, formality, glossary, filename, output_format)
676 files = {"file": input_document}
677 status, content, json = self._api_call(
678 "v2/document", data=request_data, files=files
679 )
--> 680 self._raise_for_status(status, content, json)
682 if not json:
683 json = {}
File ~\anaconda3\Lib\site-packages\deepl\translator.py:203, in Translator._raise_for_status(self, status_code, content, json, glossary, downloading_document)
198 raise DeepLException(
199 f"Not found, check server_url{message}",
200 http_status_code=status_code,
201 )
202 elif status_code == http.HTTPStatus.BAD_REQUEST:
--> 203 raise DeepLException(
204 f"Bad request{message}", http_status_code=status_code
205 )
206 elif status_code == http.HTTPStatus.TOO_MANY_REQUESTS:
207 raise TooManyRequestsException(
208 "Too many requests, DeepL servers are currently experiencing "
209 f"high load{message}",
210 should_retry=True,
211 http_status_code=status_code,
212 )
DeepLException: Bad request, message: formality is not supported for given target_lang.
Even though the API documentation clearly states ZH as a supported language pair. I am encountering the same issue with ID EL TR
The text was updated successfully, but these errors were encountered:
Yes this error is caused because formality is not supported for some languages for example ZH; please review the documentation about this parameter. The prefer_* options are offered for this purpose; formality=default works too.
When execution the following code:
it fails with
Even though the API documentation clearly states ZH as a supported language pair. I am encountering the same issue with ID EL TR
The text was updated successfully, but these errors were encountered: