mtengines
TypeScript icon, indicating that this package has built-in type declarations

1.3.3 • Public • Published

MTEngines

TypeScript library for Machine Translation (MT) engines.

Interface MTEngine provides these methods, implemented by all supported engines:

    getName(): string;
    getShortName(): string;
    getSourceLanguages(): Promise<string[]>;
    getTargetLanguages(): Promise<string[]>;
    setSourceLanguage(lang: string): void;
    getSourceLanguage(): string;
    setTargetLanguage(lang: string): void;
    getTargetLanguage(): string;
    translate(source: string): Promise<string>;
    getMTMatch(source: string): Promise<MTMatch>;
    handlesTags(): boolean;

Supported Engines

  • DeepL (Free and Pro)
  • Google Cloud Translation
  • Microsoft Azure Translator Text
  • ModernMT
  • OpenAI ChatGPT
  • Yandex Translate API

Installation

npm install mtengines

Example

import { GoogleTranslator } from "mtengines";

class TestGoogle {

    constructor() {
        let translator: GoogleTranslator = new GoogleTranslator('yourApiKey', true);
        translator.setSourceLanguage("en");
        translator.setTargetLanguage("ja");
         translator.translate("Hello World").then((result:string) => {
            console.log(result);
        }, (error:any) => {
            console.error(error);
        });
    }
}

new TestGoogle();

Package Sidebar

Install

npm i mtengines

Weekly Downloads

15

Version

1.3.3

License

EPL-1.0

Unpacked Size

82.9 kB

Total Files

36

Last publish

Collaborators

  • rmraya