Socket
Book a DemoInstallSign in
Socket

mtengines

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mtengines

Machine Translation (MT) library written in TypeScript

3.2.0
latest
Source
npmnpm
Version published
Weekly downloads
98
415.79%
Maintainers
1
Weekly downloads
 
Created
Source

MTEngines

TypeScript library for Machine Translation (MT) using various engines. It provides a unified interface to interact with different MT and AI services, allowing you to translate text between multiple languages.

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>;
    fixesTags(): boolean;
    fixTags(source: XMLElement, target: XMLElement): Promise<XMLElement>;

All supported engines implement the MTEngine interface. Methods fixMatch() and fixTags() are only implemented by AI-based engines (ChatGPTTranslator and AnthropicTranslator), all other engines throw an error when they are called.

Supported Engines

  • Anthropic Claude
  • 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();

Keywords

Machine Translation

FAQs

Package last updated on 29 Aug 2025

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.