2.2.0 • Published 4 months ago

mtengines v2.2.0

Weekly downloads
-
License
EPL-1.0
Repository
github
Last release
4 months ago

MTEngines

TypeScript library for Machine Translation (MT) engines.

Interface MTEngine provides these methods:

    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;
    fixesMatches(): boolean;
    fixMatch?(originalSource: XMLElement, matchSource: XMLElement, matchTarget: XMLElement): Promise<MTMatch>;

All supported engines implement this interface. The fixMatch() method is optional and only implemented by ChatGPTTranslator.

    getSource(): string;
    getTarget(): string;
    getConfidence(): number;
    getSourceLanguage(): string;
    getTargetLanguage(): string;
    getSourceXMLElement(): XMLElement;
    getTargetXMLElement(): XMLElement;

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');
        translator.setSourceLanguage("en");
        translator.setTargetLanguage("ja");
         translator.translate("Hello World").then((result:string) => {
            console.log(result);
        }, (error:any) => {
            console.error(error);
        });
    }
}

new TestGoogle();
2.1.2

6 months ago

2.2.0

4 months ago

2.1.1

6 months ago

2.1.4

5 months ago

2.1.3

5 months ago

2.1.0

7 months ago

1.5.0

1 year ago

1.4.0

1 year ago

2.0.0

11 months ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

2 years ago

1.0.0

2 years ago