Skip to content
This repository has been archived by the owner on Jul 4, 2021. It is now read-only.

dveselov/python-yandex-translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-yandex-translate Build Status

Python module for Yandex.Translate API.

This module is fully-compatible with Python 2.7+ and 3.3+ versions.

Installation

Use pip:

pip install yandex.translate

Usage

from yandex_translate import YandexTranslate
translate = YandexTranslate('Your API key here.')
print('Languages:', translate.langs)
print('Translate directions:', translate.directions)
print('Detect language:', translate.detect('Привет, мир!'))
print('Translate:', translate.translate('Привет, мир!', 'ru-en'))  # or just 'en'

This will output:

Languages: {'en', 'el', 'ca', 'it', ..}
Translate directions: ['az-ru', 'be-bg', 'be-cs', ..]
Detect language: 'ru'
Translate: {'text': ['Hello, world!'], 'code': 200, 'lang': 'ru-en'}

Also, it's possible to use proxies when doing requests to Yandex.Translate API - just pass proxies dictionary with data in same format that requests use.

License

WTFPL (Public Domain)