![]() I formatted the above code using black, which is why it looks different than what dwightkschruteIII included, though it is essentially doing the same thing. Where auth_key is your authentication key and string_to_translate is the text you want to translate. In order to get a correct response, you need to structure your query as such: import requests Just as a side note, the DeepL "EN" option is deprecated, and you must now use "EN-US" or "EN-GB" in your request. "path/to/original/CheBellissimaGiornata.docx", # Original File "path/to/write/to/WhatABeautifulDay.docx", # Translated File If you have full foreign language documents you would like to translate you can make a request using the DeepL package as well: anslate_document_from_filepath( Print(result.text) # "What a beautiful day" Result = anslate_text(, target_lang="EN-US") You can now also pass multiple strings in a DeepL request by putting the strings in a list: import deepl Result = anslate_text("Che bellissima giornata", target_lang="EN-US") To translate a single string you can do this: import deepl Translator = deepl.Translator("auth_key") If you don't care about hard coding your auth_key, you can set it up like so: import deepl Some of this is recycled from the DeepL documentation, but updated to answer your question. ![]() I was unaware of this before, but DeepL has a python package that can be used to make text and document translations far more easily than through the requests package.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |