Socket
Book a DemoInstallSign in
Socket

yet-another-yandex-translate

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yet-another-yandex-translate

Yet another Yandex.Translate service client

1.2.3
latest
Source
npmnpm
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

yet-another-yandex-translate Build Status Greenkeeper badge

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 } = require('yet-another-yandex-translate');

Or in ES6 and TS:

import YandexTranslate from 'yet-another-yandex-translate';

Usage

const yt = new YandexTranslate('<< YOUR YANDEX API KEY HERE >>');

Translate

Translate any type of data (string, string[], json) into one or more languages:

// Hello world!
await yt.translate('Привет мир!', {from: 'ru', to: 'en', format: 'html'});

// [ 'foo', 'bar' ]
await yt.translate([ 'foo', 'bar' ], {to: 'en', format: 'plain'});

// [{text: 'Hello world!', lang: 'en'}, {text: 'Bonjour tout le monde!', lang: 'fr'}]
await yt.translate('Привет мир!', {to: ['en', 'fr']});

// [{text: ['Hello world!', 'Hello world!'], lang: 'en'}, {text: ['Bonjour tout le monde!', 'Bonjour tout le monde!'], lang: 'fr'}]
await yt.translate(['Привет мир!', 'Привет мир!'], {to: ['en', 'fr']});   

// {
//   key1: 'Hello 1',
//   key2: 'hi 2',
//   key3: [ false, 'Hello 1', true, 'hi 2', null ],
//   key4: 123,
//   привет: [ 'hi 4' ]
// }
const test = {
    key1: 'привет 1',
    key2: 'привет 2',
    key3: [false, 'привет 1', true, 'привет 2', null],
    key4: 123,
    привет: ['привет 4']
};
await yt.translate(text, {to: 'en'});

Detect the language

Detects the language of the specified any type of data (string, string[], json).

// ru
await yt.detect('Привет мир!');

// ru
await yt.detect('Привет мир!', {hint: 'en,fr'});

// ru
await yt.detect(test, {hint: 'en,fr'});

// [{lang: 'ru'}, {lang: 'en'}]
await yt.detect(['Привет мир!', 'Hello world!']);

Get the list of supported languages

// {dirs: [], langs: {}}
await yt.getLangs();
await yt.getLangs({ui: 'en'});

Yandex Translate

Demo | Docs | List of supported languages | API Key | Statistics

Keywords

translate

FAQs

Package last updated on 27 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.