YandexTranslate v0.4.0 YandexTranslate View Source

Basic functions for requests to Yandex Translate API on Yandex Cloud

Link to this section Summary

Link to this section Functions

Detect the language of the text

Get text as a string param and return a map with language code

YandexTranslate.detect("Криївка")
# Response
%{languageCode: "uk"}

Or get a map with :text and :languageCodeHints (for specify the most likely languages).

In some languages, one and the same word has the same spelling. For example, the English word “hand” is also written as “hand” in German, Swedish, and Dutch. If the text you transmit contains words like this, Translate may detect the source language incorrectly.

To avoid mistakes, you can use the languageCodeHints field to specify which languages should be given priority when determining the language of the text

YandexTranslate.detect(%{text: "Капелюх", languageCodeHints: ["uk"]})
# Response
%{languageCode: "uk"}

Retrieves the list of supported languages.

Return a map with language code (use it for translations) and native language name

%{
  languages: [
    %{code: "az", name: "azərbaycan"},
    %{code: "sq", name: "shqip"},
    %{code: "am", name: "አማርኛ"},
    %{code: "en", name: "English"},
    %{code: "ar", name: "العربية"},
    %{code: "hy", name: "հայերեն"},
    %{code: "af", name: "Afrikaans"},
    %{code: "eu", name: "euskara"},
    ...
  ]
}
Link to this function

translate(text, targetLanguageCode)

View Source
Link to this function

translate(text, targetLanguageCode, sourceLanguageCode)

View Source