yandex-cloud-translate
Translate text with Yandex Cloud AI API
Features
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',
YC_FOLDER_ID = 'folder_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',
texts: ['text one', 'text two'],
format: 'text',
});
interface ITranslateConfig {
texts: string | string[];
to: string;
from?: string | null;
format?: 'text' | 'html';
}
Authors