Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yandex-translator

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yandex-translator

A promise based implementation of Yandex Translate API for Node.js.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

yandex-translator

Introduction

yandex-translator is a a promise based implementation of Yandex Translate API for node.js

API key

To start using Yandex Translate API we need to get an API key first, which we will get it from the API key request form after having created an account the registration page.

Installation

npm install yandex-translator --save

Getting started

Import the yandex-translator package with with the API key obtained from the API key request form.

const yandexTranslator = require('yandex-translator')(apiKey);

Functions

yandexTranslator.getAvailableLanguages([parameters])

Get the languages that yandex-translator support their translation:

yandexTranslator.getAvailableLanguages().then(
    (result) => {
        console.log(result);
    },
    (error) => {
        console.log(error);
    }
);

The parameters parameter is an object which can contain any of the following attributes:

AttributeTypeDescriptionDefault value
[ui]stringThe returned language names are output in the language corresponding to the code in this parameter. The supported language codes are shown in the list of supported languages.
[resultFormat]stringThe result format which can be either JSON or XML.JSON
[apiKey]stringAnother API key to run only this request withThe same value as the initialized API key.
yandexTranslator.detectLanguage(parameters)

Detect a text language:

yandexTranslator.detectLanguage({text: 'Bonjour'}).then(
    (result) => {
        console.log(result);
    },
    (error) => {
        console.log(error);
    }
);

The parameters parameter is an object which can contain any of the following attributes:

AttributeTypeDescriptionDefault value
text*stringThe text that we want to detect it's language.
[hints]arrayAn array of the most likely languages (they will be given preference when detecting the text language).[]
[resultFormat]stringThe result format which can be either JSON or XML.JSON
[apiKey]stringAnother API key to run only this request withThe same value as the initialized API key.
yandexTranslator.detectLanguage(parameters)

Translate a text:

yandexTranslator.translate({text: 'Bonjour', to: 'en'}).then(
    (result) => {
        console.log(result);
    },
    (error) => {
        console.log(error);
    }
);

The parameters parameter is an object which can contain any of the following attributes:

AttributeTypeDescriptionDefault value
text*stringThe text that we want to detect it's language.
to*stringThe language which the text will be translated to.
[from]stringThe source language of the text. If it's then the service will try to detect the source language automatically.
[options]integerWhether the response should include the automatically detected language of the text being translated: 1 to include the automatically detected language of the text, 0 to not1
[format]stringThe text format which can be plain (Text without markup) or html (Text in HTML format).plain
[hints]arrayAn array of the most likely languages (they will be given preference when detecting the text language).[]
[resultFormat]stringThe result format which can be either JSON or XML.JSON
[apiKey]stringAnother API key to run only this request withThe same value as the initialized API key.

Task Lists

  • Add CLI support
  • Add browser integration
  • Create tests

License

MIT.

Keywords

FAQs

Package last updated on 03 Oct 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc