yandex_translator v0.9.2 YandexTranslator View Source
Elixir client for Yandex.Translate API
Configuration (old API)
An API key can be set in your application’s config.
config :yandex_translator, api_key: "API_KEY"
Link to this section Summary
Functions
Detect language for text
Getting available languages for translation
Getting available languages for translation
Text translation
Link to this section Functions
Detect language for text
Example (old API)
iex> YandexTranslator.detect([text: "Hello", format: "json"])
{:ok, %{"code" => 200, "lang" => "en"}}
Options (old API)
key - API KEY, required or optional (if presented in config)
format - one of the [xml|json], optional, default - xml
text - text, required
hint - list of possible languages, optional, example - "en,ru"
Example (cloud API)
iex> YandexTranslator.detect([cloud: true])
Getting available languages for translation
Example (old API)
iex> YandexTranslator.langs([format: "json"])
{:ok,
%{
"dirs" => ["az-ru", "be-bg", "be-cs", "be-de", "be-en", "be-es", "be-fr",
"be-it", "be-pl", "be-ro", "be-ru", "be-sr", "be-tr", "bg-be", "bg-ru",
"bg-uk", "ca-en", "ca-ru", "cs-be", "cs-en", "cs-ru", "cs-uk", "da-en",
"da-ru", "de-be", "de-en", "de-es", "de-fr", "de-it", "de-ru", "de-tr",
"de-uk", "el-en", "el-ru", "en-be", "en-ca", "en-cs", "en-da", "en-de",
"en-el", "en-es", "en-et", "en-fi", "en-fr", "en-hu", "en-it", "en-lt", ...]
}
}
Options (old API)
key - API KEY, required or optional (if presented in configuration)
format - one of the [xml|json], optional, default - xml
ui - language code for getting language translations, optional, example - "en"
Example (cloud API)
iex> YandexTranslator.langs([cloud: true])
Text translation
Example (old API)
iex> YandexTranslator.translate([format: "json", text: "Hello", lang: "en-es"])
{:ok, %{"code" => 200, "lang" => "en-es", "text" => ["Hola"]}}
Options (old API)
key - API KEY, required or optional (if presented in config)
format - one of the [xml|json], optional, default - xml
text - text, required
lang - direction of translation, optional, example - "from-to" or "to"
Example (cloud API)
iex> YandexTranslator.translate([cloud: true])