translation python code example
Example 1: translate sentences in python
# First install translate with pip in cmd
pip install translate
# Code
from translate import Translator
translator= Translator(from_lang="german",to_lang="spanish")
translation = translator.translate("Guten Morgen")
print(translation)
Example 2: python translate
# pip3 install pandas
# pip3 install google_trans_new
import pandas as pd
from google_trans_new import google_translator
translator = google_translator()
translate_text = translator.translate('Hola mundo!', lang_src='es', lang_tgt='en')
print(translate_text) # Hello World!