A free and unlimited python API for google translate, use the reverse engineered Google Translate Ajax API.
- Install prerequisites
pip install -r requirements.txt
- Install the package
pip install git+https://github.com/krishna2206/google-translate-python.git
from google_translate_python import GoogleTranslate
translator = GoogleTranslate()
exp = """
こんにちは世界
"""
translated_text = translator.translate(exp, dest_lang='en')
print(translated_text)
-> Hello world
The translate method returns a TranslatedText
object with the following attributes:
text
: The translated textsrc_lang
: The detected source languagedest_lang
: The destination languagesrc_pronunciation
: The pronunciation of the source textdest_pronunciation
: The pronunciation of the translated text
If no attribute is specified, the translated text is returned by default.
NB : In some languages, you can get both feminine and masculine translations for some gender-neutral words, phrases and sentences. In this case, the text
attribute will be a list of strings, each string being a translation.