Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

translators

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

translators

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

  • 5.9.3
  • Source
  • PyPI
  • Socket score

Maintainers
1

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


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

Supported Translation Services

IDTranslatorNumber of Supported LanguagesAdvantageServiceStatus
1Niutrans452support the most languages in the worldNortheastern University / Niutrans, China/
2MyMemory330support the most languages in the worldTranslated, Italystable
3Alibaba221support most languages, support professional fieldAlibaba, Chinastable
4Baidu201support most languages, support professional field, support classical ChineseBaidu, Chinastable
5ModernMt200open-source, support more languages in the worldModernmt / Translated, Italystable
6VolcEngine189support more languages in the world, support professional fieldByteDance, China/
7Iciba187support the most languages in the worldKingsoft / Xiaomi, Chinastable
8Iflytek137support the most languages in the worldIflytek, China/
9Google134support more languages in the worldGoogle, Americastable(offline in China inland)
10Bing128support more languages in the worldMicrosoft, Americastable
11Lingvanex112support translation of different regions but the same languageLingvanex, Cyprusstable
12Yandex102support more languages in the world, support word to emojiYandex, Russiastable
13Itranslate101support translation of different regions but the same language, such as en-US, en-UK, en-AUItranslate, Austriastable
14SysTran52support more languages in the worldSysTran, Francestable
15Argos46open-sourceArgos / Libre, Americastable
16Apertium45open-sourceApertium, Spainstable
17Reverso42popular on Mac and IphoneReverso, Francestable
18Deepl30high quality to translate but response slowlyDeepl, Germanystable
19CloudTranslation28support main languagesXiamen University / CloudTranslation, Chinastable
20QQTranSmart22support main languagesTencent, Chinastable
21TranslateCom21good at English translationTranslateCom, Americastable
22Sogou20support more languages in the worldTencent, Chinastable
23Tilde20good at lv, de, fr translationTilde, Latvia/
24Caiyun19high quality to translate but response slowly, support professional fieldColorfulClouds, Chinastable
25QQFanyi17support main languagesTencent, China/
26TranslateMe16good at English translationTranslateMe / Neosus, Lithuania/
27Papago15good at Korean translationNaver, South Koreastable
28Mirai15good at Japanese translationMiraiTranslate, Japan/
29Youdao12support main languages, high qualityNetease, Chinastable
30Iflyrec12good at Chinese translationIflytek, Chinastable
31Hujiang12supported by baiduHujiang, Chinastable
32Yeekit10support main languagesCTC, China/
33LanguageWire8good at English translationLanguageWire, Denmarkstable
34Elia6good at Basque translationElhuyar, Spainstable
35Judic4good at European translationCrossLang, Belgium/
36Mglip3good at Mongolia translationInner Mongolia University, Chinastable
37Utibet2good at Tibet translationTibet University, Chinastable

Installation

# PYPI
pip install --upgrade translators

# Conda
conda install conda-forge::translators

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

Getting Started

import translators as ts

q_text = '季姬寂,集鸡,鸡即棘鸡。棘鸡饥叽,季姬及箕稷济鸡。'
q_html = '''<!DOCTYPE html><html><head><title>《季姬击鸡记》</title></head><body><p>还有另一篇文章《施氏食狮史》。</p></body></html>'''

### usage
_ = ts.preaccelerate_and_speedtest()  # Optional. Caching sessions in advance, which can help improve access speed.

print(ts.translators_pool)
print(ts.translate_text(q_text))
print(ts.translate_html(q_html, translator='alibaba'))

### parameters
help(ts.translate_text)

"""
translate_text(query_text: str, translator: str = 'bing', from_language: str = 'auto', to_language: str = 'en', **kwargs) -> Union[str, dict]
    :param query_text: str, must.
    :param translator: str, default 'bing'.
    :param from_language: str, default 'auto'.
    :param to_language: str, default 'en'.
    :param if_use_preacceleration: bool, default False.
    :param **kwargs:
            :param is_detail_result: bool, default False.
            :param professional_field: str, default None. Support alibaba(), baidu(), caiyun(), cloudTranslation(), elia(), sysTran(), youdao(), volcEngine() only.
            :param timeout: float, default None.
            :param proxies: dict, default None.
            :param sleep_seconds: float, default 0.
            :param update_session_after_freq: int, default 1000.
            :param update_session_after_seconds: float, default 1500.
            :param if_use_cn_host: bool, default False. Support google(), bing() only.                
            :param reset_host_url: str, default None. Support google(), yandex() only.
            :param if_check_reset_host_url: bool, default True. Support google(), yandex() only.
            :param if_ignore_empty_query: bool, default False.
            :param limit_of_length: int, default 20000.
            :param if_ignore_limit_of_length: bool, default False.
            :param if_show_time_stat: bool, default False.
            :param show_time_stat_precision: int, default 2.
            :param if_print_warning: bool, default True.
            :param lingvanex_mode: str, default 'B2C', choose from ("B2C", "B2B").
            :param myMemory_mode: str, default "web", choose from ("web", "api").
    :return: str or dict
"""

Supported Languages

LanguageLanguage of TranslatorGoogleYandexBingBaiduAlibabaTencentYoudaoSogouDeeplCaiyunArgosothers...
englishenYYYYYYYYYYY...
chinesezhYYYYYYYYYYY
arabicarYYYY(ara)YYYYY
russianruYYYYYYYYYYY
frenchfrYYYY(fra)YYYYYYY
germandeYYYYYYYYY
spanishesYYYY(spa)YYYYYYY
portugueseptYYY(pt/pt-pt)YYYYYYY
italianitYYYYYYYYYY
japanesejaYYYY(jp)YYYYYY
koreankoYYYY(kor)YYYY
greekelYYYYYY
dutchnlYYYYYYY
hindihiYYYYYY
turkishtrYYYYYYY
malaymsYYYYY
thaithYYYYYYY
vietnameseviYYYY(vie)YYYYY
indonesianidYYYYYYYY
hebrewheY(iw)YYY
polishplYYYYYYY
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
......

About Chinese Language

LanguageLanguage of TranslatorGoogleYandexBingBaiduAlibabaTencentYoudaoSogouIcibaIflytekCaiyunDeeplArgosItranslateReversoTranslateComPapagoUtibet
Chinese(简体)zh-CHSY(zh-CN)Y(zh)Y(zh-Hans)Y(zh)Y(zh)Y(zh)YYY(zh)Y(zh)Y(zh)Y(zh)Y(zh)Y(zh-CN)Y(zh/chi)...Y(zh-CN)Y(zh)
Chinese(繁体)zh-CHTY(zh-TW)Y(zh-Hant)Y(cht)Y(zh-TW)YY(cnt)Y(zh-TW)Y(zh-TW)
Chinese(文言文)wywY
Chinese(粤语)yueYYYYYY(zh-HK)
Chinese(内蒙语)mnN[外蒙]N[外蒙]Y[内蒙]N[外蒙]
Chinese(维吾尔语)uyY
Chinese(藏语)tiYY
Chinese(白苗文)mwwYYY
Chinese(彝语)iiY
Chinese(苗语)hmnY
Chinese(壮语)zyb

Debug Tips

Linux Runtime Environment

  1. To support javascript runtime environment, you should download and install Node.js.
  2. Function baidu() doesn't work on Linux without desktop.

HttpError 4xx

  1. Check whether you made high frequency requests, especially httperror 429.
  2. Check whether this service is provided in your region.
  3. Detail to solve HttpError itself.
  4. Issue me, thanks.

NetworkError or ProxyError

  1. Check whether the network is connected correctly.
  2. Check the proxy are enabled on your computer. If it is enabled, try turning it off or otherwise.

Star History

Star History Chart

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