A library that help translating text in Python, with possibility of adding new translation module.
For now, only the DeepL traductor is available.
poetry install
poetry shell
python3 -m build
python3 -m pip install dist/ApiTranslator-VERSION.tar.gz
python3 -m pytest
For the DeepL translator module
from ApiTranslator import DeepLTranslator
trans_module = DeepLTranslator(target_language_full="FRENCH",source_language=None)
To know all the language support by the library, check Language support by the library
lower
trans_module.auth("yourkey")
trans_module.auth()
NOTE: When you call auth() without argument, it will search in the .env file if there is a
KEY_DEEPL_API
key.
You will need an api key to run the project, go to the https://www.deepl.com/en/pro-api website, and create your account for free
Then, store your API KEY to the .env file as the variable KEY_DEEPL_API
text_in_french :str = trans_module.translate("I'm an English sentence.")
NOTE: The DeepLModule will try to translate with formality if it supports for the language. To know the list of language support please see https://support.deepl.com/hc/en-us/articles/4406432463762-About-the-formal-informal-feature
['BULGARIAN', 'CZECH', 'DANISH', 'GERMAN', 'GREEK', 'ENGLISH', 'SPANISH', 'ESTONIAN', 'FINNISH', 'FRENCH', 'HUNGARIAN', 'INDONESIAN', 'ITALIAN', 'JAPANESE', 'LITHUANIAN', 'LATVIAN', 'DUTCH', 'POLISH', 'PORTUGUESE', 'ROMANIAN', 'RUSSIAN', 'SLOVAK', 'SLOVENIAN', 'TURKISH', 'SWEDISH', 'CHINESE']
.