Package: translate-api
Translatorsis a library which aims to bringfree, multiple, enjoyabletranslation to individuals and students in Python. It based on the translation interface of Google, Yandex, Microsoft(Bing), Baidu, Alibaba, Tencent, NetEase(Youdao), Sogou, Deepl, Caiyun, etc.The old version is calledtranslate-api, and it is updated synchronously now.InstallationFrom PyPIFrom SourceGetting StartedImport libraryLanguageProfessional FieldPropertyRequestsHostDetail ResultTranslate HTMLHelpIssuesLinux Runtime EnvironmentSupported Country and Region ServiceHTTPError 4xxMore About TranslatorsFeaturesSupport LanguageAbout Chinese LanguageLicenseInstallationFrom PyPI# Windows, Mac, Linuxpipinstalltranslators--upgrade# Linux javascript runtime environment:sudoyum-yinstallnodejsFrom Sourcegitclonehttps://github.com/UlionTse/translators.gitcdtranslators
pythonsetup.pyinstallGetting Startedimporttranslatorsastswyw_text='季姬寂，集鸡，鸡即棘鸡。棘鸡饥叽，季姬及箕稷济鸡。'chs_text='季姬感到寂寞，罗集了一些鸡来养，鸡是那种出自荆棘丛中的野鸡。野鸡饿了唧唧叫，季姬就拿竹箕中的谷物喂鸡。'html_text='''<!DOCTYPE html><html><head><title>我是标题</title></head><body><p>我是文章《你的父亲》</p></body></html>'''# input languagesprint(ts.google(wyw_text))# default: from_language='auto', to_language='en'## output language_mapprint(ts._google.language_map)# professional fieldprint(ts.alibaba(wyw_text,professional_field='general'))# ("general","message","offer")print(ts.baidu(wyw_text,professional_field='common'))# ('common','medicine','electronics','mechanics')print(ts.caiyun(wyw_text,from_language='zh',professional_field=None))# ("medicine","law","machinery")# propertyrs=[ts.tencent(x)forxin[wyw_text,chs_text]]print(ts._tencent.query_count)print(dir(ts._tencent))# requestsprint(ts.youdao(wyw_text,sleep_seconds=5,proxies={}))# host serviceprint(ts.google(wyw_text,if_use_cn_host=True))print(ts.bing(wyw_text,if_use_cn_host=False))# detail resultprint(ts.sogou(wyw_text,is_detail_result=True))# translate htmlprint(ts.translate_html(html_text,translator=ts.google,to_language='en',n_jobs=-1))# helphelp(ts.google)IssuesLinux Runtime EnvironmentTo support javascript runtime environment, you shouldsudo yum -y install nodejs.PS,ts.baidu()does not work on Linux without desktop.Supported Country and Region ServiceIf you have requests error, please check whether this service is provided in your country or region.Check the website abouteg: help(ts.google).HTTPError 4xxPlease check whether you made high frequency requests.Please check whether this service is provided in your country or region.Detail to solveHTTPErroritself.Pleaseissue me, thanks.More About TranslatorsFeaturesTranslatorSupported Language CountAdvantageGoogle108support the most languages in the worldYandex99support more languages in the world, support word to emoji, unstableBing77support more languages in the worldSogou61support more languages in the worldBaidu28support more languages, support professional fieldTencent17support more languagesYoudao14support more languagesAlibaba12support more languages, support professional fieldDeepl24high quality to translate but response slowly, unstableCaiyun6high quality to translate but response slowly, support professional fieldSupport LanguageLanguageLanguage of TranslatorGoogleYandexBingBaiduAlibabaTencentYoudaoSogouDeeplCaiyunenglishenYYYYYYYYYYchinesezhYYYYYYYYYYarabicarYYYY(ara)YYYYrussianruYYYYYYYYYYfrenchfrYYYY(fra)YYYYYYgermandeYYYYYYYYspanishesYYYY(spa)YYYYYYportugueseptYYY(pt/pt-pt)YYYYYYitalianitYYYYYYYYYjapanesejaYYYY(jp)YYYYYkoreankoYYYY(kor)YYYgreekelYYYYYYdutchnlYYYYYYYhindihiYYYYYturkishtrYYYYYYmalaymsYYYYYthaithYYYYYYYvietnameseviYYYY(vie)YYYYindonesianidYYYYYYYhebrewheY(iw)YYYpolishplYYYYYYmongolianmnYYczechcsYYYYYYhungarianhuYYYYYYestonianetYYYY(est)YYbulgarianbgYYYY(bul)YYdanishdaYYYY(dan)YYfinnishfiYYYY(fin)YYromanianroYYYY(rom)YYswedishsvYYYY(swe)YYslovenianslYYYY(slo)YYpersian/farsifaYYYYbosnianbsYYY(bs-Latn)Y(bs-Latn)serbiansrYYY(sr-Latn/sr-Cyrl)Y(sr-Latn/sr-Cyrl)fijianfjYYfilipinotlYYY(fil)Y(fil)haitiancreolehtYYYYcatalancaYYYYcroatianhrYYYYlatvianlvYYYYYlithuanianltYYYYYurduurYYYYukrainianukYYYYwelshcyYYYYtahitityYYtongantoYYswahiliswYYYYsamoansmYYYslovakskYYYYYafrikaansafYYYYnorwegiannoYYYYbengalibnYYY(bn-BD)YmalagasymgYYYYmaltesemtYYYYqueretaro otomiotqYYklingon/tlhingan holtlhYYgujaratiguYYYtamiltaYYYteluguteYYYpunjabipaYYYamharicamYYazerbaijaniazYYbashkirbaYbelarusianbeYYcebuanocebYYchuvashcvYesperantoeoYYbasqueeuYYirishgaYYYemojiemjY......More supported language, eg:print(ts._google.language_map)About Chinese LanguageLanguageLanguage of TranslatorGoogleYandexBingBaiduAlibabaTencentYoudaoSogouDeeplCaiyunchinese(简体)zh-CHSY(zh-CN)Y(zh)Y(zh-Hans)Y(zh)Y(zh)Y(zh)YYY(zh)Y(zh)chinese(繁体)zh-CHTY(zh-TW)Y(zh-Hant)Y(cht)Y(zh-TW)Ychinese(文言文)wywYchinese(粤语)yueYYYchinese(白苗文)mwwYYLicenseMIT Llicense