yet-another-yandex-translate
Translate any type of data (string, string[], json) into one or more languages.
Installation
-
Sign up for a Yandex API key at https://translate.yandex.com/developers/keys
-
Install this package in your project:
$ npm install --save yet-another-yandex-translate
Adding to your project
In Node.js
Call require to get the instance:
const YandexTranslate = ;
Or in ES6 and TS:
;
Usage
;
Translate
Translate any type of data (string, string[], json) into one or more languages:
// Hello world!await yt.translate'Привет мир!', ; // [ 'foo', 'bar' ]await yt.translate, ; // [{text: 'Hello world!', lang: 'en'}, {text: 'Bonjour tout le monde!', lang: 'fr'}]await yt.translate'Привет мир!', ; // [{text: ['Hello world!', 'Hello world!'], lang: 'en'}, {text: ['Bonjour tout le monde!', 'Bonjour tout le monde!'], lang: 'fr'}]await yt.translate, ; // {// key1: 'Hello 1',// key2: 'hi 2',// key3: [ false, 'Hello 1', true, 'hi 2', null ],// key4: 123,// привет: [ 'hi 4' ]// };await yt.translatetext, ;
Detect the language
Detects the language of the specified any type of data (string, string[], json).
// ruawait yt.detect'Привет мир!'; // ruawait yt.detect'Привет мир!', ; // ruawait yt.detecttest, ; // [{lang: 'ru'}, {lang: 'en'}]await yt.detect;
Get the list of supported languages
// {dirs: [], langs: {}}await yt.getLangs;await yt.getLangs;
Yandex Translate
Demo | Docs | List of supported languages | API Key | Statistics