import pandas as pd
from translate import Translator
translator = Translator(to_lang="zh")
translation = translator.translate("Hello")
translation
# 批量翻译
from pygtrans import Translate
data['Keyword_before'] = "需要翻译的文件内容" #补充需要翻译的文件内容
client = Translate(proxies={'http': 'http://localhost:10809', 'https': 'http://localhost:10809'})
texts = client.translate(data['Keyword_before'].tolist(), source='it', target='en')
Phrase = []
new_data = data.copy()
for text in texts:
Phrase.append(text.translatedText)
new_data.insert(0,"Phrase",Phrase)
如果有梯子,可以直接使用Google的文档翻译:
Google翻译链接: https://translate.google.com.hk/?hl=zh-CN&sourceid=cnhp&sl=auto&tl=zh-CN&op=docs
参考链接: 利用python批量将excel中文翻译成英文