代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
"""Personal_translator.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1lHb0mCvF6Ie3QaTt3VfqlNjNs6vuV5qJ
"""
# uncomment the line to intall googletrans library
# ! pip install googletrans
from googletrans import Translator
# make a simple function that will translate any language to english
def text_translator(Text):
translator = Translator()
translated = translator.translate(Text, dest='en')
return translated.text
text_translator('Cidades brasileiras integram programa de preservação de florestas') # portuguese to english
text_translator('Guten Morgen, wie gehts?') # german to english
text_translator('Ami tumake bhalobashi') # bengali to english
text_translator('ਮੈਨੂੰ ਇੱਕ ਗੱਲ ਦੱਸੋ') # punjabi to english
text_translator('I am fine') # english text remains constant
def eng2punj_translator(Text): # english to punjabi translator
translator = Translator()
translated = translator.translate(Text, dest='pa')
return translated.text
eng2punj_translator('Meet you soon')
def eng2beng_translator(Text): # english to bengali translator
translator = Translator()
translated = translator.translate(Text, dest='bn')
return translated.text
eng2beng_translator('So happy to see you')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。