Socket
Socket
Sign inDemoInstall

yandex-cloud-translate

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    yandex-cloud-translate

Translate text with Yandex Cloud AI API


Version published
Weekly downloads
7
decreased by-12.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

yandex-cloud-translate

Translate text with Yandex Cloud AI API

Features

  • ts included

Installation

Install my-project with npm

  npm i yandex-cloud-translate

or

  yarn add yandex-cloud-translate

Usage/Examples

import { Yandex } from 'yandex-cloud-translate';

const config = {
    YC_OAUTH_TOKEN = 'token', // https://cloud.yandex.com/en-ru/docs/iam/concepts/authorization/oauth-token
    YC_FOLDER_ID = 'folder_id' // https://cloud.yandex.com/en-ru/docs/resource-manager/operations/folder/get-id
}

const Ya = new Yandex(config);

or if you have valid process.env, just create in .env file YC_OAUTH_TOKEN and YC_FOLDER_ID

import { Yandex } from 'yandex-cloud-translate';
const Ya = new Yandex();
const translated = await Ya.translate({
    to: 'fr',
    from: 'en', // or don`t set to auto
    texts: ['text one', 'text two'], // or texts: 'text one'. string, or array of strings
    format: 'text', // or 'html'. default: 'text'
});

//
interface ITranslateConfig {
    texts: string | string[]; // if a string - result will be a string, if array of strings - array of strings
    to: string; // ISO ru, en, fr ... etc
    from?: string | null; // ISO ru, en, fr ... etc
    format?: 'text' | 'html';
}

Authors

  • @jsix

Keywords

FAQs

Last updated on 10 Mar 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc