A translation package
Project description
translation is a python translation package based on website service.
It provids google, youdao, baidu, iciba translation service.
Installation
pip install translation
Usage
from translation import baidu, google, youdao, iciba
print(
baidu('hello world!', dst = 'zh'),
youdao('hello world!', dst = 'zh-CN'),
iciba('hello world!', dst = 'zh'),
google('hello world!', dst = 'zh-CN'))
Documents
You may find document here
Advanced usage
Proxies
You may not use some of the function without proxies.
Proxies can be set as following.
from translation import google, ConnectError
# 127.0.0.1:1080 is a vaild proxies
try:
print(google('hello world!', dst = 'zh-CN', proxies = {'http': '127.0.0.1:1080'}))
except ConnectError:
print('Invaild proxy')
Default
You may change default setting such as:
default source language (auto if not set)
default destination language (zh-CN if not set)
default translation (youdao if not set)
default proxies (no proxy if not set)
from translation import (set_default_translation, set_default_language,
set_default_proxies, get, ConnectError)
set_default_translation('google')
set_default_language('auto', 'zh-CN')
set_default_proxies({'http': '127.0.0.1:1080'})
try:
print(get('hello world!'))
except ConnectError:
print('Invaild proxy')
More
More functions are introduced in the document.
Language
Language list of all the translation are provided in document.
el : Greek,
eo : Esperanto,
en : English,
af : Afrikaans,
sw : Swahili,
ca : Catalan,
it : Italian,
iw : Hebrew,
sv : Swedish,
cs : Czech,
cy : Welsh,
ar : Arabic,
ur : Urdu,
ga : Irish,
eu : Basque,
et : Estonian,
az : Azerbaijani,
id : Indonesian,
es : Spanish,
ru : Russian,
gl : Galician,
nl : Dutch,
pt : Portuguese,
la : Latin,
tr : Turkish,
tl : Filipino,
lv : Latvian,
lt : Lithuanian,
th : Thai,
vi : Vietnamese,
gu : Gujarati,
ro : Romanian,
is : Icelandic,
pl : Polish,
ta : Tamil,
yi : Yiddish,
be : Belarusian,
fr : French,
bg : Bulgarian,
uk : Ukrainian,
hr : Croatian,
bn : Bengali,
sl : Slovenian,
ht : Haitian Creole,
da : Danish,
fa : Persian,
hi : Hindi,
fi : Finnish,
hu : Hungarian,
ja : Japanese,
ka : Georgian,
te : Telugu,
zh-TW : Chinese Traditional,
sq : Albanian,
no : Norwegian,
ko : Korean,
kn : Kannada,
mk : Macedonian,
zh-CN : Chinese Simplified,
sk : Slovak,
mt : Maltese,
de : German,
ms : Malay,
sr : Serbian
Comments
If you have any problem or suggestion, you may contact me in this issue.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for translation-1.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16f6441be9f2d38179a1ce0c7a02e462086b18e15bd40faf06c83c234543aa6b |
|
MD5 | 16e83e27d6649aa89256a9b2238a8247 |
|
BLAKE2b-256 | 381719a07a18a7e913dc800e111d6a718d1828454d64c62e9be4181e4c97f5a2 |