1.0.6 • Published 5 months ago

@toil/translate v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

translate

GitHub Actions npm ru en

A library for free and not only using various translation APIs, which supports working with JavaScript, TypeScript, and also has built-in separated types for Typebox.

Installation

Installation via Bun:

bun add @toil/translate

Installation via NPM:

npm install @toil/translate

Getting started

To start working with the API, you need to create a Translation Client. This can be done using the code provided below.

const client = new TranslationClient({
  service: TranslationService.yandexbrowser,
});

const translatedResult = await client.translate(
  "The quick brown fox jumps over the lazy dog",
);

const detectResult = await client.detect(
  "The quick brown fox jumps over the lazy dog",
);

const langs = await client.getLangs();

You can see more code examples here

Available services

StatusServiceFunctionsLimits
YandexBrowserTranslateDetectGetLangs10k chars/req10k chars/req
YandexCloudTranslateDetectGetLangs2k chars/req1k chars/req
YandexTranslateTranslateDetectGetLangs10k chars/req10k chars/req
YandexGPT*¹TranslateDetectGetLangs10k chars/req10k chars/req
MSEdgeTranslateDetectGetLangs50k chars/req50k chars/req
BingTranslateDetectGetLangs1k chars/req1k chars/req
LibreTranslate*²TranslateDetectGetLangs2k chars/req2k chars/req

*¹ - translation using YandexGPT only works for the en-ru pair, For all other cases, a translation similar to YandexTranslate is used

*² - by default, obtaining a secret key is disabled. Please install apiKey or enable allowUnsafeEval when creating the client

Build

To build, you must have:

Don't forget to install the dependencies:

bun install

Start building:

bun build:all

Tests

The library has minimal test coverage to check it's performance.

Run the tests:

bun test
1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

7 months ago

1.0.3

8 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago