Socket
Socket
Sign inDemoInstall

translate-api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

translate-api

Translators is a library which aims to bring free, multiple, enjoyable translation to individuals and students in Python.


Maintainers
1

PyPI - Version PyPI - License PyPI - Python PyPI - Status PyPI - Wheel Downloads


Translators is a library which aims to bring free, multiple, enjoyable translation 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 called translate-api downloads, and it is updated synchronously now.

Installation

From PyPI

# Windows, Mac, Linux
pip install translators --upgrade

# Linux javascript runtime environment:
sudo yum -y install nodejs

From Source

git clone https://github.com/UlionTse/translators.git
cd translators
python setup.py install

Getting Started

import translators as ts

wyw_text = '季姬寂,集鸡,鸡即棘鸡。棘鸡饥叽,季姬及箕稷济鸡。'
chs_text = '季姬感到寂寞,罗集了一些鸡来养,鸡是那种出自荆棘丛中的野鸡。野鸡饿了唧唧叫,季姬就拿竹箕中的谷物喂鸡。'
html_text = '''
<!DOCTYPE html>
<html>
<head>
	<title>我是标题</title>
</head>
<body>
<p>我是文章《你的父亲》</p>
</body>
</html>
'''

# input languages
print(ts.google(wyw_text)) # default: from_language='auto', to_language='en'

## output language_map
print(ts._google.language_map)

# professional field
print(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")

# property
rs = [ts.tencent(x) for x in [wyw_text, chs_text]]
print(ts._tencent.query_count)
print(dir(ts._tencent))

# requests
print(ts.youdao(wyw_text, sleep_seconds=5, proxies={}))

# host service
print(ts.google(wyw_text, if_use_cn_host=True))
print(ts.bing(wyw_text, if_use_cn_host=False))

# detail result
print(ts.sogou(wyw_text, is_detail_result=True))

# translate html
print(ts.translate_html(html_text, translator=ts.google, to_language='en', n_jobs=-1))

# help
help(ts.google)

Issues

Linux Runtime Environment

  1. To support javascript runtime environment, you should sudo yum -y install nodejs .
  2. PS, ts.baidu() does not work on Linux without desktop.

Supported Country and Region Service

  1. If you have requests error, please check whether this service is provided in your country or region.
  2. Check the website about eg: help(ts.google).

HTTPError 4xx

  1. Please check whether you made high frequency requests.
  2. Please check whether this service is provided in your country or region.
  3. Detail to solve HTTPError itself.
  4. Please issue me, thanks.

More About Translators

Features

TranslatorSupported Language CountAdvantage
Google108support the most languages in the world
Yandex99support more languages in the world, support word to emoji, unstable
Bing77support more languages in the world
Sogou61support more languages in the world
Baidu28support more languages, support professional field
Tencent17support more languages
Youdao14support more languages
Alibaba12support more languages, support professional field
Deepl24high quality to translate but response slowly, unstable
Caiyun6high quality to translate but response slowly, support professional field

Support Language

LanguageLanguage of TranslatorGoogleYandexBingBaiduAlibabaTencentYoudaoSogouDeeplCaiyun
englishenYYYYYYYYYY
chinesezhYYYYYYYYYY
arabicarYYYY(ara)YYYY
russianruYYYYYYYYYY
frenchfrYYYY(fra)YYYYYY
germandeYYYYYYYY
spanishesYYYY(spa)YYYYYY
portugueseptYYY(pt/pt-pt)YYYYYY
italianitYYYYYYYYY
japanesejaYYYY(jp)YYYYY
koreankoYYYY(kor)YYY
greekelYYYYYY
dutchnlYYYYYYY
hindihiYYYYY
turkishtrYYYYYY
malaymsYYYYY
thaithYYYYYYY
vietnameseviYYYY(vie)YYYY
indonesianidYYYYYYY
hebrewheY(iw)YYY
polishplYYYYYY
mongolianmnYY
czechcsYYYYYY
hungarianhuYYYYYY
estonianetYYYY(est)YY
bulgarianbgYYYY(bul)YY
danishdaYYYY(dan)YY
finnishfiYYYY(fin)YY
romanianroYYYY(rom)YY
swedishsvYYYY(swe)YY
slovenianslYYYY(slo)YY
persian/farsifaYYYY
bosnianbsYYY(bs-Latn)Y(bs-Latn)
serbiansrYYY(sr-Latn/sr-Cyrl)Y(sr-Latn/sr-Cyrl)
fijianfjYY
filipinotlYYY(fil)Y(fil)
haitiancreolehtYYYY
catalancaYYYY
croatianhrYYYY
latvianlvYYYYY
lithuanianltYYYYY
urduurYYYY
ukrainianukYYYY
welshcyYYYY
tahitityYY
tongantoYY
swahiliswYYYY
samoansmYYY
slovakskYYYYY
afrikaansafYYYY
norwegiannoYYYY
bengalibnYYY(bn-BD)Y
malagasymgYYYY
maltesemtYYYY
queretaro otomiotqYY
klingon/tlhingan holtlhYY
gujaratiguYYY
tamiltaYYY
teluguteYYY
punjabipaYYY
amharicamYY
azerbaijaniazYY
bashkirbaY
belarusianbeYY
cebuanocebYY
chuvashcvY
esperantoeoYY
basqueeuYY
irishgaYYY
emojiemjY
......

More supported language, eg:

print(ts._google.language_map)

About Chinese Language

LanguageLanguage of TranslatorGoogleYandexBingBaiduAlibabaTencentYoudaoSogouDeeplCaiyun
chinese(简体)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)Y
chinese(文言文)wywY
chinese(粤语)yueYYY
chinese(白苗文)mwwYY

License

MIT Llicense

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc