Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

yandex

Build Status Codacy Badge License: MIT Documentation Status

A python wrapper around the Yandex API

Testing

Create a file named "test_config.py" in the tests/ folder, and paste in the following :

API_KEY = "<your_api_token_here>"

You can get an API token here

Usage

Instantiate the Yandex object with your API token. You can then use the translate method to translate text from one language to another.

from yandex import Yandex

tr = Yandex("MY_API_TOKEN")
tr.translate("Hello World", "fr")
tr.translate("Bonjour tout le monde!", to_lang="en", from_lang="fr")

Yandex can detect which language the text is in, therefore, the from_lang argument is optional. You can also translate text formatted in html

tr.translate("<p>Hello World!</p>", "fr", format="html")

Or you can use the API to guess a language from a text sample :

tr.guess_language("Hello World!")

You can get a list of all available language code pairs with the get_language_pairs method, and a dictionary mapping all the language codes to their names with the get_language_map method

About

A python wrapper around the Yandex API

Resources

License

Packages

No packages published

Languages