PIP-Talk - Week 43
PIP-Talk - Week 43!
The topic for this week is translator with deep-translator
Need to translate a text using python ?
Deep-translator is a flexible FREE and UNLIMITED tool to translate between different languages in a simple way using multiple translators. There are other libraries that can be used for this task, but most of them are buggy, not free, limited, not supported anymore or complex to use.
Use cases
When you should use it ?
- If you want to translate text using python
- If you want to translate from a file
- If you want to get translations from many sources and not only one
- If you want to automate translations
- If you want to compare different translations
- If you want to detect language automatically
Features
Support for:
- google translate
- microsoft translator
- Pons translator
- Linguee translator
- Mymemory translator
- Yandex translator
- QcriTranslator translator
- DeeplTranslator translator
- Papago translator
- Libre translator
- Automatic single language detection
- Batch language detection
- Translate directly from a text file
- Get multiple translation for a word
- Translate directly from terminal
License
MIT License (MIT)
Install deep-translator
$ pip install -U deep-translator
Examples
Translate from english to german
Here is a simple example where we use the GoogleTranslator class to translate a text into german.
from deep_translator import GoogleTranslator
translated = GoogleTranslator(source='auto', target='de').translate("keep it up, you are awesome") # output -> Weiter so, du bist großartig
Batch translation
You could also do batch translations by adding a list of words/phrases or by adding a whole file. In this example we translate a list of words.
from deep_translator import (GoogleTranslator,
batch_detection)
texts = ["hallo welt", "guten morgen"]
translated = GoogleTranslator('de', 'en').translate_batch(texts)
Links and resources
- Homepage: https://github.com/nidhaloff/deep_translator
- Documentation: https://deep-translator.readthedocs.io/en/latest/
- Source Code: https://github.com/nidhaloff/deep_translator
- PyPI: https://pypi.org/project/deep-translator/