.
--------------------------------------------------------------------------------
/README_history.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | * * *
15 |
16 | **Translators** is a library that aims to bring **free, multiple, enjoyable** translations to individuals and students in Python.
17 |
18 |
19 | Supported Translation Services
20 |
21 | | ID | Translator | Number of Supported Languages | Advantage | Service | Status |
22 | | --- | --------------------------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------- |
23 | | 1 | [Niutrans](https://niutrans.com/trans) | 452 | support the most languages in the world | [Northeastern University](http://english.neu.edu.cn/) / [Niutrans](https://github.com/NiuTrans), China | / |
24 | | 2 | [MyMemory](https://mymemory.translated.net) | 330 | support the most languages in the world | [Translated](https://translatedlabs.com/welcome), Italy | stable |
25 | | 3 | [Alibaba](https://translate.alibaba.com) | 221 | support most languages, support professional field | [Alibaba](https://damo.alibaba.com/about?lang=en), China | stable |
26 | | 4 | [Baidu](https://fanyi.baidu.com) | 201 | support most languages, support professional field, support classical Chinese | [Baidu](https://ir.baidu.com/company-overview), China | stable |
27 | | 5 | [ModernMt](https://www.modernmt.com/translate) | 200 | open-source, support more languages in the world | [Modernmt](https://github.com/modernmt) / [Translated](https://translatedlabs.com/welcome), Italy | stable |
28 | | 6 | [VolcEngine](https://translate.volcengine.com) | 189 | support more languages in the world, support professional field | [ByteDance](https://www.bytedance.com/en/), China | / |
29 | | 7 | [Iciba](https://www.iciba.com/fy) | 187 | support the most languages in the world | [Kingsoft](https://www.wps.com/about-us/) / [Xiaomi](https://www.mi.com/us/about/), China | stable |
30 | | 8 | [Iflytek](https://fanyi.xfyun.cn/console/trans/text) | 137 | support the most languages in the world | [Iflytek](https://www.iflytek.com/en/about-us/about.html), China | / |
31 | | 9 | [Google](https://translate.google.com) | 134 | support more languages in the world | [Google](https://about.google/), America | stable(offline in China inland) |
32 | | 10 | [Bing](https://www.bing.com/Translator) | 128 | support more languages in the world | [Microsoft](https://www.microsoft.com/en-us/about), America | stable |
33 | | 11 | [Lingvanex](https://lingvanex.com/demo) | 112 | support translation of different regions but the same language | [Lingvanex](https://lingvanex.com/about-us/), Cyprus | stable |
34 | | 12 | [Yandex](https://translate.yandex.com) | 102 | support more languages in the world, support word to emoji | [Yandex](https://yandex.com/company/), Russia | stable |
35 | | 13 | [Itranslate](https://itranslate.com/webapp) | 101 | support translation of different regions but the same language, such as en-US, en-UK, en-AU | [Itranslate](https://itranslate.com/about), Austria | stable |
36 | | 14 | [SysTran](https://www.systransoft.com/translate/) | 52 | support more languages in the world | [SysTran](https://www.systransoft.com/systran/), France | stable |
37 | | 15 | [Argos](https://libretranslate.com) | 46 | open-source | [Argos](https://github.com/argosopentech) / [Libre](https://github.com/LibreTranslate), America | stable |
38 | | 16 | [Apertium](https://www.apertium.org/) | 45 | open-source | [Apertium](https://github.com/apertium), Spain | stable |
39 | | 17 | [Reverso](https://www.reverso.net/text-translation) | 42 | popular on Mac and Iphone | [Reverso](https://www.corporate-translation.reverso.com/about-us), France | stable |
40 | | 18 | [Deepl](https://www.deepl.com/translator) | 30 | high quality to translate but response slowly | [Deepl](https://jobs.deepl.com/l/en), Germany | stable |
41 | | 19 | [CloudTranslation](https://www.cloudtranslation.com/#/translate) | 28 | support main languages | [Xiamen University](http://nlp.xmu.edu.cn/) / [CloudTranslation](https://www.cloudtranslation.com/#/about), China | stable |
42 | | 20 | [QQTranSmart](https://transmart.qq.com) | 22 | support main languages | [Tencent](https://www.tencent.com/en-us/about.html), China | stable |
43 | | 21 | [TranslateCom](https://www.translate.com/machine-translation) | 21 | good at English translation | [TranslateCom](https://www.translate.com/about-us), America | stable |
44 | | 22 | [Sogou](https://fanyi.sogou.com/text) | 20 | support more languages in the world | [Tencent](https://www.tencent.com/en-us/about.html), China | stable |
45 | | 23 | [Tilde](https://translate.tilde.com/) | 20 | good at lv, de, fr translation | [Tilde](https://tilde.com/about), Latvia | / |
46 | | 24 | [Caiyun](https://fanyi.caiyunapp.com) | 19 | high quality to translate but response slowly, support professional field | [ColorfulClouds](http://caiyunapp.com/jobs/), China | stable |
47 | | 25 | [QQFanyi](https://fanyi.qq.com) | 17 | support main languages | [Tencent](https://www.tencent.com/en-us/about.html), China | / |
48 | | 26 | [TranslateMe](https://translateme.network/) | 16 | good at English translation | [TranslateMe](https://translateme.network/our-team/) / [Neosus](https://neosus.net/about/), Lithuania | / |
49 | | 27 | [Papago](https://papago.naver.com) | 15 | good at Korean translation | [Naver](https://www.navercorp.com/en/naver/company), South Korea | stable |
50 | | 28 | [Mirai](https://miraitranslate.com/trial/) | 15 | good at Japanese translation | [MiraiTranslate](https://miraitranslate.com/en/company/), Japan | / |
51 | | 29 | [Youdao](https://ai.youdao.com/product-fanyi-text.s) | 12 | support main languages, high quality | [Netease](https://ir.netease.com/company-overview/corporate-profile), China | stable |
52 | | 30 | [Iflyrec](https://fanyi.iflyrec.com) | 12 | good at Chinese translation | [Iflytek](https://www.iflytek.com/en/about-us/about.html), China | stable |
53 | | 31 | [Hujiang](https://dict.hjenglish.com/app/trans) | 12 | supported by baidu | [Hujiang](https://www.hujiang.com/about/intro), China | stable |
54 | | 32 | [Yeekit](https://www.yeekit.com/site/translate) | 10 | support main languages | [CTC](https://www.ctpc.com.cn/cms/enAboutUs.htm), China | / |
55 | | 33 | [LanguageWire](https://www.languagewire.com/en/technology/languagewire-translate) | 8 | good at English translation | [LanguageWire](https://www.languagewire.com/about-us), Denmark | stable |
56 | | 34 | [Elia](https://elia.eus/translator) | 6 | good at Basque translation | [Elhuyar](https://www.elhuyar.eus/eu/nor-gara), Spain | stable |
57 | | 35 | [Judic](https://judic.io/en/translate) | 4 | good at European translation | [CrossLang](https://crosslang.com/about-us/), Belgium | / |
58 | | 36 | [Mglip](http://fy.mglip.com/pc) | 3 | good at Mongolia translation | [Inner Mongolia University](https://www.imu.edu.cn/yw/Home.htm), China | stable |
59 | | 37 | [Utibet](http://mt.utibet.edu.cn/mt) | 2 | good at Tibet translation | [Tibet University](http://www.utibet.edu.cn/), China | stable |
60 |
61 |
62 |
63 |
64 | Installation
65 |
66 | ```sh
67 | # PYPI
68 | pip install --upgrade translators
69 |
70 | # Conda
71 | conda install conda-forge::translators
72 | conda install -c conda-forge translators
73 |
74 | # Source
75 | git clone https://github.com/UlionTse/translators.git
76 | cd translators
77 | python setup.py install
78 | ```
79 |
80 |
81 |
82 |
83 | Getting Started
84 |
85 | ```python
86 | import translators as ts
87 |
88 | q_text = '季姬寂,集鸡,鸡即棘鸡。棘鸡饥叽,季姬及箕稷济鸡。'
89 | q_html = '''《季姬击鸡记》还有另一篇文章《施氏食狮史》。
'''
90 |
91 | ### usage
92 | _ = ts.preaccelerate_and_speedtest() # Optional. Caching sessions in advance, which can help improve access speed.
93 |
94 | print(ts.translators_pool)
95 | print(ts.translate_text(q_text))
96 | print(ts.translate_html(q_html, translator='alibaba'))
97 |
98 | ### parameters
99 | help(ts.translate_text)
100 |
101 | """
102 | translate_text(query_text: str, translator: str = 'bing', from_language: str = 'auto', to_language: str = 'en', **kwargs) -> Union[str, dict]
103 | :param query_text: str, must.
104 | :param translator: str, default 'alibaba'.
105 | :param from_language: str, default 'auto'.
106 | :param to_language: str, default 'en'.
107 | :param if_use_preacceleration: bool, default False.
108 | :param **kwargs:
109 | :param is_detail_result: bool, default False.
110 | :param http_client: str, default 'requests' (except reverso). Union['requests', 'niquests', 'httpx', 'cloudscraper']
111 | :param professional_field: str, default None. Support alibaba(), baidu(), caiyun(), cloudTranslation(), elia(), sysTran(), youdao(), volcEngine() only.
112 | :param timeout: float, default None.
113 | :param proxies: dict, default None.
114 | :param sleep_seconds: float, default 0.
115 | :param update_session_after_freq: int, default 1000.
116 | :param update_session_after_seconds: float, default 1500.
117 | :param if_use_cn_host: bool, default False. Support google(), bing() only.
118 | :param reset_host_url: str, default None. Support google(), yandex() only.
119 | :param if_check_reset_host_url: bool, default True. Support google(), yandex() only.
120 | :param if_ignore_empty_query: bool, default False.
121 | :param limit_of_length: int, default 20000.
122 | :param if_ignore_limit_of_length: bool, default False.
123 | :param if_show_time_stat: bool, default False.
124 | :param show_time_stat_precision: int, default 2.
125 | :param if_print_warning: bool, default True.
126 | :param lingvanex_mode: str, default 'B2C', choose from ("B2C", "B2B").
127 | :param myMemory_mode: str, default "web", choose from ("web", "api").
128 | :return: str or dict
129 | """
130 | ```
131 |
132 |
133 |
134 |
135 | Supported Languages
136 |
137 | | Language | Language of Translator | [Google](https://translate.google.com) | [Yandex](https://translate.yandex.com) | [Bing](https://www.bing.com/Translator) | [Baidu](https://fanyi.baidu.com) | [Alibaba](https://translate.alibaba.com) | [Tencent](https://fanyi.qq.com) | [Youdao](https://fanyi.youdao.com) | [Sogou](https://fanyi.sogou.com) | [Deepl](https://www.deepl.com/translator) | [Caiyun](https://fanyi.caiyunapp.com) | [Argos](https://translate.argosopentech.com) | others... |
138 | | -------------------- | ---------------------- | -------------------------------------- | -------------------------------------- | --------------------------------------- | -------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------- | -------------------------------- | ----------------------------------------- | ------------------------------------- | -------------------------------------------- | --------- |
139 | | english | en | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | ... |
140 | | chinese | zh | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | |
141 | | arabic | ar | Y | Y | Y | Y(ara) | Y | Y | Y | Y | | | Y | |
142 | | russian | ru | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | |
143 | | french | fr | Y | Y | Y | Y(fra) | Y | Y | Y | Y | Y | Y | Y | |
144 | | german | de | Y | Y | Y | Y | | Y | Y | Y | Y | | Y | |
145 | | spanish | es | Y | Y | Y | Y(spa) | Y | Y | Y | Y | Y | Y | Y | |
146 | | portuguese | pt | Y | Y | Y(pt/pt-pt) | Y | Y | Y | Y | Y | Y | | Y | |
147 | | italian | it | Y | Y | Y | Y | Y | Y | Y | Y | Y | | Y | |
148 | | japanese | ja | Y | Y | Y | Y(jp) | | Y | Y | Y | Y | Y | Y | |
149 | | korean | ko | Y | Y | Y | Y(kor) | | Y | Y | Y | | | Y | |
150 | | greek | el | Y | Y | Y | Y | | | | Y | Y | | | |
151 | | dutch | nl | Y | Y | Y | Y | | | Y | Y | Y | | | |
152 | | hindi | hi | Y | Y | Y | | | Y | | Y | | | Y | |
153 | | turkish | tr | Y | Y | Y | | Y | Y | | Y | | | Y | |
154 | | malay | ms | Y | Y | Y | | | Y | | Y | | | | |
155 | | thai | th | Y | Y | Y | Y | Y | Y | | Y | | | | |
156 | | vietnamese | vi | Y | Y | Y | Y(vie) | Y | Y | Y | Y | | | Y | |
157 | | indonesian | id | Y | Y | Y | | Y | Y | Y | Y | | | Y | |
158 | | hebrew | he | Y(iw) | Y | Y | | | | | Y | | | | |
159 | | polish | pl | Y | Y | Y | Y | | | | Y | Y | | Y | |
160 | | mongolian | mn | Y | Y | | | | | | | | | | |
161 | | czech | cs | Y | Y | Y | Y | | | | Y | Y | | | |
162 | | hungarian | hu | Y | Y | Y | Y | | | | Y | Y | | | |
163 | | estonian | et | Y | Y | Y | Y(est) | | | | Y | Y | | | |
164 | | bulgarian | bg | Y | Y | Y | Y(bul) | | | | Y | Y | | | |
165 | | danish | da | Y | Y | Y | Y(dan) | | | | Y | Y | | | |
166 | | finnish | fi | Y | Y | Y | Y(fin) | | | | Y | Y | | | |
167 | | romanian | ro | Y | Y | Y | Y(rom) | | | | Y | Y | | | |
168 | | swedish | sv | Y | Y | Y | Y(swe) | | | | Y | Y | | | |
169 | | slovenian | sl | Y | Y | Y | Y(slo) | | | | Y | Y | | | |
170 | | persian/farsi | fa | Y | Y | Y | | | | | Y | | | | |
171 | | bosnian | bs | Y | Y | Y(bs-Latn) | | | | | Y(bs-Latn) | | | | |
172 | | serbian | sr | Y | Y | Y(sr-Latn/sr-Cyrl) | | | | | Y(sr-Latn/sr-Cyrl) | | | | |
173 | | fijian | fj | | | Y | | | | | Y | | | | |
174 | | filipino | tl | Y | Y | Y(fil) | | | | | Y(fil) | | | | |
175 | | haitiancreole | ht | Y | Y | Y | | | | | Y | | | | |
176 | | catalan | ca | Y | Y | Y | | | | | Y | | | | |
177 | | croatian | hr | Y | Y | Y | | | | | Y | | | | |
178 | | latvian | lv | Y | Y | Y | | | | | Y | Y | | | |
179 | | lithuanian | lt | Y | Y | Y | | | | | Y | Y | | | |
180 | | urdu | ur | Y | Y | Y | | | | | Y | | | | |
181 | | ukrainian | uk | Y | Y | Y | | | | | Y | | | | |
182 | | welsh | cy | Y | Y | Y | | | | | Y | | | | |
183 | | tahiti | ty | | | Y | | | | | Y | | | | |
184 | | tongan | to | | | Y | | | | | Y | | | | |
185 | | swahili | sw | Y | Y | Y | | | | | Y | | | | |
186 | | samoan | sm | Y | | Y | | | | | Y | | | | |
187 | | slovak | sk | Y | Y | Y | | | | | Y | Y | | | |
188 | | afrikaans | af | Y | Y | Y | | | | | Y | | | | |
189 | | norwegian | no | Y | Y | Y | | | | | Y | | | | |
190 | | bengali | bn | Y | Y | Y(bn-BD) | | | | | Y | | | | |
191 | | malagasy | mg | Y | Y | Y | | | | | Y | | | | |
192 | | maltese | mt | Y | Y | Y | | | | | Y | | | | |
193 | | queretaro otomi | otq | | | Y | | | | | Y | | | | |
194 | | klingon/tlhingan hol | tlh | | | Y | | | | | Y | | | | |
195 | | gujarati | gu | Y | Y | Y | | | | | | | | | |
196 | | tamil | ta | Y | Y | Y | | | | | | | | | |
197 | | telugu | te | Y | Y | Y | | | | | | | | | |
198 | | punjabi | pa | Y | Y | Y | | | | | | | | | |
199 | | amharic | am | Y | Y | | | | | | | | | | |
200 | | azerbaijani | az | Y | Y | | | | | | | | | | |
201 | | bashkir | ba | | Y | | | | | | | | | | |
202 | | belarusian | be | Y | Y | | | | | | | | | | |
203 | | cebuano | ceb | Y | Y | | | | | | | | | | |
204 | | chuvash | cv | | Y | | | | | | | | | | |
205 | | esperanto | eo | Y | Y | | | | | | | | | | |
206 | | basque | eu | Y | Y | | | | | | | | | | |
207 | | irish | ga | Y | Y | Y | | | | | | | | | |
208 | | emoji | emj | | Y | | | | | | | | | | |
209 | | ... | ... | | | | | | | | | | | | |
210 |
211 |
212 | About Chinese Language
213 |
214 | | Language | Language of Translator | [Google](https://translate.google.com) | [Yandex](https://translate.yandex.com) | [Bing](https://www.bing.com/Translator) | [Baidu](https://fanyi.baidu.com) | [Alibaba](https://translate.alibaba.com) | [Tencent](https://fanyi.qq.com) | [Youdao](https://fanyi.youdao.com) | [Sogou](https://fanyi.sogou.com) | [Iciba](https://www.iciba.com/fy) | [Iflytek](https://fanyi.xfyun.cn/console/trans/text) | [Caiyun](https://fanyi.caiyunapp.com) | [Deepl](https://www.deepl.com/translator) | [Argos](https://translate.argosopentech.com) | [Itranslate](https://itranslate.com/webapp) | [Reverso](https://www.reverso.net/text-translation) | [TranslateCom](https://www.translate.com/machine-translation) | [Papago](https://papago.naver.com) | [Utibet](http://mt.utibet.edu.cn/mt) |
215 | | ------------- | ---------------------- | -------------------------------------- | -------------------------------------- | --------------------------------------- | -------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------- | -------------------------------- | --------------------------------- | ---------------------------------------------------- | ------------------------------------- | ----------------------------------------- | -------------------------------------------- | ------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------- | ---------------------------------- | ------------------------------------ |
216 | | Chinese(简体) | zh-CHS | Y(zh-CN) | Y(zh) | Y(zh-Hans) | Y(zh) | Y(zh) | Y(zh) | Y | Y | Y(zh) | Y(zh) | Y(zh) | Y(zh) | Y(zh) | Y(zh-CN) | Y(zh/chi) | ... | Y(zh-CN) | Y(zh) |
217 | | Chinese(繁体) | zh-CHT | Y(zh-TW) | | Y(zh-Hant) | Y(cht) | Y(zh-TW) | | | Y | Y(cnt) | | | | | Y(zh-TW) | | | Y(zh-TW) | |
218 | | Chinese(文言文) | wyw | | | | Y | | | | | | | | | | | | | | |
219 | | Chinese(粤语) | yue | | | Y | Y | | | | Y | Y | Y | | | | Y(zh-HK) | | | | |
220 | | Chinese(内蒙语) | mn | N[外蒙] | N[外蒙] | | | | | | | | Y[内蒙] | | | | N[外蒙] | | | | |
221 | | Chinese(维吾尔语) | uy | | | | | | | | | Y | | | | | | | | | |
222 | | Chinese(藏语) | ti | | | | | | | | | Y | | | | | | | | | Y |
223 | | Chinese(白苗文) | mww | | | Y | | | | | Y | Y | | | | | | | | | |
224 | | Chinese(彝语) | ii | | | | | | | | | | Y | | | | | | | | |
225 | | Chinese(苗语) | hmn | | | | | | | | | | | | | | Y | | | | |
226 | | Chinese(壮语) | zyb | | | | | | | | | | | | | | | | | | |
227 |
228 |
229 |
230 |
231 |
232 | Debug Tips
233 |
234 | ### Linux Runtime Environment
235 |
236 | 1. To support javascript runtime environment, you should [download and install Node.js](https://nodejs.org/en/download/).
237 | 2. Function baidu() doesn't work on Linux without desktop.
238 |
239 | ### HttpError 4xx
240 |
241 | 1. Check whether you made high frequency requests, especially httperror 429.
242 | 2. Check whether this service is provided in your region.
243 | 3. Detail to solve [HttpError](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) itself.
244 | 4. [Issue me](https://github.com/UlionTse/translators/issues), thanks.
245 |
246 | ### NetworkError or ProxyError
247 |
248 | 1. Check whether the network is connected correctly.
249 | 2. Check the proxy are enabled on your computer. If it is enabled, try turning it off or otherwise.
250 |
251 |
252 |
253 |
254 | Star History
255 |
256 | [](https://star-history.com/#UlionTse/translators&Date)
257 |
258 |
259 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | * * *
15 |
16 | **Translators** is a library that aims to bring **free, multiple, enjoyable** translations to individuals and students in Python.
17 |
18 | - [Supported Translation Services](#supported-translation-services)
19 | - [Installation](#installation)
20 | - [Getting Started](#getting-started)
21 | - [Command Line Interface](#Command-Line-Interface)
22 | - [Supported Languages](#supported-languages)
23 | - [Debug Tips](#debug-tips)
24 | - [Star History](#star-history)
25 |
26 | ## Supported Translation Services
27 |
28 | | ID | Translator | Number of Supported Languages | Advantage | Service | Status |
29 | | --- | --------------------------------------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------- |
30 | | 1 | [Niutrans](https://niutrans.com/trans) | 452 | support the most languages in the world | [Northeastern University](http://english.neu.edu.cn/) / [Niutrans](https://github.com/NiuTrans), China | / |
31 | | 2 | [MyMemory](https://mymemory.translated.net) | 330 | support the most languages in the world | [Translated](https://translatedlabs.com/welcome), Italy | stable |
32 | | 3 | [Alibaba](https://translate.alibaba.com) | 221 | support most languages, support professional field | [Alibaba](https://damo.alibaba.com/about?lang=en), China | stable |
33 | | 4 | [Baidu](https://fanyi.baidu.com) | 201 | support most languages, support professional field, support classical Chinese | [Baidu](https://ir.baidu.com/company-overview), China | stable |
34 | | 5 | [ModernMt](https://www.modernmt.com/translate) | 200 | open-source, support more languages in the world | [Modernmt](https://github.com/modernmt) / [Translated](https://translatedlabs.com/welcome), Italy | stable |
35 | | 6 | [VolcEngine](https://translate.volcengine.com) | 189 | support more languages in the world, support professional field | [ByteDance](https://www.bytedance.com/en/), China | / |
36 | | 7 | [Iciba](https://www.iciba.com/fy) | 187 | support the most languages in the world | [Kingsoft](https://www.wps.com/about-us/) / [Xiaomi](https://www.mi.com/us/about/), China | stable |
37 | | 8 | [Iflytek](https://fanyi.xfyun.cn/console/trans/text) | 137 | support the most languages in the world | [Iflytek](https://www.iflytek.com/en/about-us/about.html), China | / |
38 | | 9 | [Google](https://translate.google.com) | 134 | support more languages in the world | [Google](https://about.google/), America | stable(offline in China inland) |
39 | | 10 | [Bing](https://www.bing.com/Translator) | 128 | support more languages in the world | [Microsoft](https://www.microsoft.com/en-us/about), America | stable |
40 | | 11 | [Lingvanex](https://lingvanex.com/demo) | 112 | support translation of different regions but the same language | [Lingvanex](https://lingvanex.com/about-us/), Cyprus | stable |
41 | | 12 | [Yandex](https://translate.yandex.com) | 102 | support more languages in the world, support word to emoji | [Yandex](https://yandex.com/company/), Russia | stable |
42 | | 13 | [Itranslate](https://itranslate.com/webapp) | 101 | support translation of different regions but the same language, such as en-US, en-UK, en-AU | [Itranslate](https://itranslate.com/about), Austria | stable |
43 | | 14 | [SysTran](https://www.systransoft.com/translate/) | 52 | support more languages in the world | [SysTran](https://www.systransoft.com/systran/), France | stable |
44 | | 15 | [Argos](https://libretranslate.com) | 46 | open-source | [Argos](https://github.com/argosopentech) / [Libre](https://github.com/LibreTranslate), America | stable |
45 | | 16 | [Apertium](https://www.apertium.org/) | 45 | open-source | [Apertium](https://github.com/apertium), Spain | stable |
46 | | 17 | [Reverso](https://www.reverso.net/text-translation) | 42 | popular on Mac and Iphone | [Reverso](https://www.corporate-translation.reverso.com/about-us), France | stable |
47 | | 18 | [Deepl](https://www.deepl.com/translator) | 30 | high quality to translate but response slowly | [Deepl](https://jobs.deepl.com/l/en), Germany | stable |
48 | | 19 | [CloudTranslation](https://www.cloudtranslation.com/#/translate) | 28 | support main languages | [Xiamen University](http://nlp.xmu.edu.cn/) / [CloudTranslation](https://www.cloudtranslation.com/#/about), China | stable |
49 | | 20 | [QQTranSmart](https://transmart.qq.com) | 22 | support main languages | [Tencent](https://www.tencent.com/en-us/about.html), China | stable |
50 | | 21 | [TranslateCom](https://www.translate.com/machine-translation) | 21 | good at English translation | [TranslateCom](https://www.translate.com/about-us), America | stable |
51 | | 22 | [Sogou](https://fanyi.sogou.com/text) | 20 | support more languages in the world | [Tencent](https://www.tencent.com/en-us/about.html), China | stable |
52 | | 23 | [Tilde](https://translate.tilde.com/) | 20 | good at lv, de, fr translation | [Tilde](https://tilde.com/about), Latvia | / |
53 | | 24 | [Caiyun](https://fanyi.caiyunapp.com) | 19 | high quality to translate but response slowly, support professional field | [ColorfulClouds](http://caiyunapp.com/jobs/), China | stable |
54 | | 25 | [QQFanyi](https://fanyi.qq.com) | 17 | support main languages | [Tencent](https://www.tencent.com/en-us/about.html), China | / |
55 | | 26 | [TranslateMe](https://translateme.network/) | 16 | good at English translation | [TranslateMe](https://translateme.network/our-team/) / [Neosus](https://neosus.net/about/), Lithuania | / |
56 | | 27 | [Papago](https://papago.naver.com) | 15 | good at Korean translation | [Naver](https://www.navercorp.com/en/naver/company), South Korea | stable |
57 | | 28 | [Mirai](https://miraitranslate.com/trial/) | 15 | good at Japanese translation | [MiraiTranslate](https://miraitranslate.com/en/company/), Japan | / |
58 | | 29 | [Youdao](https://ai.youdao.com/product-fanyi-text.s) | 12 | support main languages, high quality | [Netease](https://ir.netease.com/company-overview/corporate-profile), China | stable |
59 | | 30 | [Iflyrec](https://fanyi.iflyrec.com) | 12 | good at Chinese translation | [Iflytek](https://www.iflytek.com/en/about-us/about.html), China | stable |
60 | | 31 | [Hujiang](https://dict.hjenglish.com/app/trans) | 12 | supported by baidu | [Hujiang](https://www.hujiang.com/about/intro), China | stable |
61 | | 32 | [Yeekit](https://www.yeekit.com/site/translate) | 10 | support main languages | [CTC](https://www.ctpc.com.cn/cms/enAboutUs.htm), China | / |
62 | | 33 | [LanguageWire](https://www.languagewire.com/en/technology/languagewire-translate) | 8 | good at English translation | [LanguageWire](https://www.languagewire.com/about-us), Denmark | stable |
63 | | 34 | [Elia](https://elia.eus/translator) | 6 | good at Basque translation | [Elhuyar](https://www.elhuyar.eus/eu/nor-gara), Spain | stable |
64 | | 35 | [Judic](https://judic.io/en/translate) | 4 | good at European translation | [CrossLang](https://crosslang.com/about-us/), Belgium | / |
65 | | 36 | [Mglip](http://fy.mglip.com/pc) | 3 | good at Mongolia translation | [Inner Mongolia University](https://www.imu.edu.cn/yw/Home.htm), China | / |
66 | | 37 | [Utibet](http://mt.utibet.edu.cn/mt) | 2 | good at Tibet translation | [Tibet University](http://www.utibet.edu.cn/), China | stable |
67 |
68 | ## Installation
69 |
70 | ```sh
71 | # PYPI
72 | pip install --upgrade translators
73 |
74 | # Conda
75 | conda install conda-forge::translators
76 |
77 | # Source
78 | git clone https://github.com/UlionTse/translators.git
79 | cd translators
80 | python setup.py install
81 | ```
82 |
83 | ## Getting Started
84 |
85 | ```python
86 | import translators as ts
87 |
88 | q_text = '季姬寂,集鸡,鸡即棘鸡。棘鸡饥叽,季姬及箕稷济鸡。'
89 | q_html = '''《季姬击鸡记》还有另一篇文章《施氏食狮史》。
'''
90 |
91 | ### usage
92 | _ = ts.preaccelerate_and_speedtest() # Optional. Caching sessions in advance, which can help improve access speed.
93 |
94 | print(ts.translators_pool)
95 | print(ts.translate_text(q_text))
96 | print(ts.translate_html(q_html, translator='alibaba'))
97 |
98 | ### parameters
99 | help(ts.translate_text)
100 |
101 | """
102 | translate_text(query_text: str, translator: str = 'bing', from_language: str = 'auto', to_language: str = 'en', **kwargs) -> Union[str, dict]
103 | :param query_text: str, must.
104 | :param translator: str, default 'alibaba'.
105 | :param from_language: str, default 'auto'.
106 | :param to_language: str, default 'en'.
107 | :param if_use_preacceleration: bool, default False.
108 | :param **kwargs:
109 | :param is_detail_result: bool, default False.
110 | :param http_client: str, default 'requests' (except reverso). Union['requests', 'niquests', 'httpx', 'cloudscraper']
111 | :param professional_field: str, default None. Support alibaba(), baidu(), caiyun(), cloudTranslation(), elia(), sysTran(), youdao(), volcEngine() only.
112 | :param timeout: Optional[float], default None.
113 | :param proxies: Optional[dict], default None.
114 | :param sleep_seconds: float, default 0.
115 | :param update_session_after_freq: int, default 1000.
116 | :param update_session_after_seconds: float, default 1500.
117 | :param if_use_cn_host: bool, default False. Support google(), bing() only.
118 | :param reset_host_url: str, default None. Support google(), yandex() only.
119 | :param if_check_reset_host_url: bool, default True. Support google(), yandex() only.
120 | :param if_ignore_empty_query: bool, default False.
121 | :param limit_of_length: int, default 20000.
122 | :param if_ignore_limit_of_length: bool, default False.
123 | :param if_show_time_stat: bool, default False.
124 | :param show_time_stat_precision: int, default 2.
125 | :param if_print_warning: bool, default True.
126 | :param lingvanex_mode: str, default 'B2C', choose from ("B2C", "B2B").
127 | :param myMemory_mode: str, default "web", choose from ("web", "api").
128 | :return: str or dict
129 | """
130 | ```
131 |
132 | ## Command Line Interface
133 |
134 | You can leverage a simple CLI named **fanyi** that ships with **translators**.
135 |
136 | ```sh
137 | >fanyi --help ─╯
138 | usage: fanyi input [--help] [--translator] [--from] [--to] [--is_html] [--version]
139 |
140 | Translators(fanyi for CLI) is a library that aims to bring free, multiple, enjoyable translations to individuals and students in Python.
141 |
142 | positional arguments:
143 | input raw text or path to a file to be translated.
144 |
145 | options:
146 | --help show help information.
147 | --translator e.g. bing, google, yandex, etc...
148 | --from from_language, default `auto` detected.
149 | --to to_language, default `en`.
150 | --is_html is_html, default `0`.
151 | --version Show version information.
152 | ```
153 |
154 | ## Supported Languages
155 |
156 | | Language | Language of Translator | [Google](https://translate.google.com) | [Yandex](https://translate.yandex.com) | [Bing](https://www.bing.com/Translator) | [Baidu](https://fanyi.baidu.com) | [Alibaba](https://translate.alibaba.com) | [Tencent](https://fanyi.qq.com) | [Youdao](https://fanyi.youdao.com) | [Sogou](https://fanyi.sogou.com) | [Deepl](https://www.deepl.com/translator) | [Caiyun](https://fanyi.caiyunapp.com) | [Argos](https://translate.argosopentech.com) | others... |
157 | | -------------------- | ---------------------- | -------------------------------------- | -------------------------------------- | --------------------------------------- | -------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------- | -------------------------------- | ----------------------------------------- | ------------------------------------- | -------------------------------------------- | --------- |
158 | | english | en | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | ... |
159 | | chinese | zh | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | |
160 | | arabic | ar | Y | Y | Y | Y(ara) | Y | Y | Y | Y | | | Y | |
161 | | russian | ru | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | |
162 | | french | fr | Y | Y | Y | Y(fra) | Y | Y | Y | Y | Y | Y | Y | |
163 | | german | de | Y | Y | Y | Y | | Y | Y | Y | Y | | Y | |
164 | | spanish | es | Y | Y | Y | Y(spa) | Y | Y | Y | Y | Y | Y | Y | |
165 | | portuguese | pt | Y | Y | Y(pt/pt-pt) | Y | Y | Y | Y | Y | Y | | Y | |
166 | | italian | it | Y | Y | Y | Y | Y | Y | Y | Y | Y | | Y | |
167 | | japanese | ja | Y | Y | Y | Y(jp) | | Y | Y | Y | Y | Y | Y | |
168 | | korean | ko | Y | Y | Y | Y(kor) | | Y | Y | Y | | | Y | |
169 | | greek | el | Y | Y | Y | Y | | | | Y | Y | | | |
170 | | dutch | nl | Y | Y | Y | Y | | | Y | Y | Y | | | |
171 | | hindi | hi | Y | Y | Y | | | Y | | Y | | | Y | |
172 | | turkish | tr | Y | Y | Y | | Y | Y | | Y | | | Y | |
173 | | malay | ms | Y | Y | Y | | | Y | | Y | | | | |
174 | | thai | th | Y | Y | Y | Y | Y | Y | | Y | | | | |
175 | | vietnamese | vi | Y | Y | Y | Y(vie) | Y | Y | Y | Y | | | Y | |
176 | | indonesian | id | Y | Y | Y | | Y | Y | Y | Y | | | Y | |
177 | | hebrew | he | Y(iw) | Y | Y | | | | | Y | | | | |
178 | | polish | pl | Y | Y | Y | Y | | | | Y | Y | | Y | |
179 | | mongolian | mn | Y | Y | | | | | | | | | | |
180 | | czech | cs | Y | Y | Y | Y | | | | Y | Y | | | |
181 | | hungarian | hu | Y | Y | Y | Y | | | | Y | Y | | | |
182 | | estonian | et | Y | Y | Y | Y(est) | | | | Y | Y | | | |
183 | | bulgarian | bg | Y | Y | Y | Y(bul) | | | | Y | Y | | | |
184 | | danish | da | Y | Y | Y | Y(dan) | | | | Y | Y | | | |
185 | | finnish | fi | Y | Y | Y | Y(fin) | | | | Y | Y | | | |
186 | | romanian | ro | Y | Y | Y | Y(rom) | | | | Y | Y | | | |
187 | | swedish | sv | Y | Y | Y | Y(swe) | | | | Y | Y | | | |
188 | | slovenian | sl | Y | Y | Y | Y(slo) | | | | Y | Y | | | |
189 | | persian/farsi | fa | Y | Y | Y | | | | | Y | | | | |
190 | | bosnian | bs | Y | Y | Y(bs-Latn) | | | | | Y(bs-Latn) | | | | |
191 | | serbian | sr | Y | Y | Y(sr-Latn/sr-Cyrl) | | | | | Y(sr-Latn/sr-Cyrl) | | | | |
192 | | fijian | fj | | | Y | | | | | Y | | | | |
193 | | filipino | tl | Y | Y | Y(fil) | | | | | Y(fil) | | | | |
194 | | haitiancreole | ht | Y | Y | Y | | | | | Y | | | | |
195 | | catalan | ca | Y | Y | Y | | | | | Y | | | | |
196 | | croatian | hr | Y | Y | Y | | | | | Y | | | | |
197 | | latvian | lv | Y | Y | Y | | | | | Y | Y | | | |
198 | | lithuanian | lt | Y | Y | Y | | | | | Y | Y | | | |
199 | | urdu | ur | Y | Y | Y | | | | | Y | | | | |
200 | | ukrainian | uk | Y | Y | Y | | | | | Y | | | | |
201 | | welsh | cy | Y | Y | Y | | | | | Y | | | | |
202 | | tahiti | ty | | | Y | | | | | Y | | | | |
203 | | tongan | to | | | Y | | | | | Y | | | | |
204 | | swahili | sw | Y | Y | Y | | | | | Y | | | | |
205 | | samoan | sm | Y | | Y | | | | | Y | | | | |
206 | | slovak | sk | Y | Y | Y | | | | | Y | Y | | | |
207 | | afrikaans | af | Y | Y | Y | | | | | Y | | | | |
208 | | norwegian | no | Y | Y | Y | | | | | Y | | | | |
209 | | bengali | bn | Y | Y | Y(bn-BD) | | | | | Y | | | | |
210 | | malagasy | mg | Y | Y | Y | | | | | Y | | | | |
211 | | maltese | mt | Y | Y | Y | | | | | Y | | | | |
212 | | queretaro otomi | otq | | | Y | | | | | Y | | | | |
213 | | klingon/tlhingan hol | tlh | | | Y | | | | | Y | | | | |
214 | | gujarati | gu | Y | Y | Y | | | | | | | | | |
215 | | tamil | ta | Y | Y | Y | | | | | | | | | |
216 | | telugu | te | Y | Y | Y | | | | | | | | | |
217 | | punjabi | pa | Y | Y | Y | | | | | | | | | |
218 | | amharic | am | Y | Y | | | | | | | | | | |
219 | | azerbaijani | az | Y | Y | | | | | | | | | | |
220 | | bashkir | ba | | Y | | | | | | | | | | |
221 | | belarusian | be | Y | Y | | | | | | | | | | |
222 | | cebuano | ceb | Y | Y | | | | | | | | | | |
223 | | chuvash | cv | | Y | | | | | | | | | | |
224 | | esperanto | eo | Y | Y | | | | | | | | | | |
225 | | basque | eu | Y | Y | | | | | | | | | | |
226 | | irish | ga | Y | Y | Y | | | | | | | | | |
227 | | emoji | emj | | Y | | | | | | | | | | |
228 | | ... | ... | | | | | | | | | | | | |
229 |
230 | ### About Chinese Language
231 |
232 | | Language | Language of Translator | [Google](https://translate.google.com) | [Yandex](https://translate.yandex.com) | [Bing](https://www.bing.com/Translator) | [Baidu](https://fanyi.baidu.com) | [Alibaba](https://translate.alibaba.com) | [Tencent](https://fanyi.qq.com) | [Youdao](https://fanyi.youdao.com) | [Sogou](https://fanyi.sogou.com) | [Iciba](https://www.iciba.com/fy) | [Iflytek](https://fanyi.xfyun.cn/console/trans/text) | [Caiyun](https://fanyi.caiyunapp.com) | [Deepl](https://www.deepl.com/translator) | [Argos](https://translate.argosopentech.com) | [Itranslate](https://itranslate.com/webapp) | [Reverso](https://www.reverso.net/text-translation) | [TranslateCom](https://www.translate.com/machine-translation) | [Papago](https://papago.naver.com) | [Utibet](http://mt.utibet.edu.cn/mt) |
233 | | ------------- | ---------------------- | -------------------------------------- | -------------------------------------- | --------------------------------------- | -------------------------------- | ---------------------------------------- | ------------------------------- | ---------------------------------- | -------------------------------- | --------------------------------- | ---------------------------------------------------- | ------------------------------------- | ----------------------------------------- | -------------------------------------------- | ------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------- | ---------------------------------- | ------------------------------------ |
234 | | Chinese(简体) | zh-CHS | Y(zh-CN) | Y(zh) | Y(zh-Hans) | Y(zh) | Y(zh) | Y(zh) | Y | Y | Y(zh) | Y(zh) | Y(zh) | Y(zh) | Y(zh) | Y(zh-CN) | Y(zh/chi) | ... | Y(zh-CN) | Y(zh) |
235 | | Chinese(繁体) | zh-CHT | Y(zh-TW) | | Y(zh-Hant) | Y(cht) | Y(zh-TW) | | | Y | Y(cnt) | | | | | Y(zh-TW) | | | Y(zh-TW) | |
236 | | Chinese(文言文) | wyw | | | | Y | | | | | | | | | | | | | | |
237 | | Chinese(粤语) | yue | | | Y | Y | | | | Y | Y | Y | | | | Y(zh-HK) | | | | |
238 | | Chinese(内蒙语) | mn | N[外蒙] | N[外蒙] | | | | | | | | Y[内蒙] | | | | N[外蒙] | | | | |
239 | | Chinese(维吾尔语) | uy | | | | | | | | | Y | | | | | | | | | |
240 | | Chinese(藏语) | ti | | | | | | | | | Y | | | | | | | | | Y |
241 | | Chinese(白苗文) | mww | | | Y | | | | | Y | Y | | | | | | | | | |
242 | | Chinese(彝语) | ii | | | | | | | | | | Y | | | | | | | | |
243 | | Chinese(苗语) | hmn | | | | | | | | | | | | | | Y | | | | |
244 | | Chinese(壮语) | zyb | | | | | | | | | | | | | | | | | | |
245 |
246 |
247 |
248 | ## Debug Tips
249 |
250 | ### Linux Runtime Environment
251 |
252 | 1. To support javascript runtime environment, you should [download and install Node.js](https://nodejs.org/en/download/).
253 | 2. Function baidu() doesn't work on Linux without desktop.
254 |
255 | ### HttpError 4xx
256 |
257 | 1. Check whether you made high frequency requests, especially httperror 429.
258 | 2. Check whether this service is provided in your region.
259 | 3. Detail to solve [HttpError](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) itself.
260 | 4. [Issue me](https://github.com/UlionTse/translators/issues), thanks.
261 |
262 | ### NetworkError or ProxyError
263 |
264 | 1. Check whether the network is connected correctly.
265 | 2. Check the proxy are enabled on your computer. If it is enabled, try turning it off or otherwise.
266 |
267 | ## Star History
268 |
269 | [](https://star-history.com/#UlionTse/translators&Date)
270 |
--------------------------------------------------------------------------------