cloud-translator
Use the same api to call the third party translator apis, such as google, tencent, baidu.
Prerequisite
Python 3.7 or more latest version
Installation
pip install cloud-translator
Usage
The library support GoogleTranslator, TencentTranslator, BaiduTranslator, where GoogleTranslator depends on py-googletrans which not needs appid and appkey, but is not stable and probably blocked by google.
TencentTranslator and BaiduTranslator are rewritted with reference to the offical demo script to support python 3.7 version
from translator import *
translator = GoogleTranslator()
print(translator.translate('我是中国人', dest='en'))
translator = BaiduTranslator(appid, appkey)
print(translator.translate('我是中国人', dest='en'))
translator = TencentTranslator(appid, appkey)
print(translator.translate('我是中国人', dest='en'))
translate_func = throttle(seconds=1)(translator.translate)
for i in range(100):
translate_func('我是中国人', dest='en')