npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mtengines

v4.8.0

Published

Machine Translation (MT) library written in TypeScript

Readme

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 (QwenTranslator, ChatGPTTranslator, AnthropicTranslator, MistralTranslator and GeminiTranslator), all other engines throw an error when they are called.

Supported Engines

  • Alibaba Qwen Models
  • Anthropic Claude
  • DeepL (Free and Pro)
  • Google Cloud Translation
  • Google Gemini
  • Microsoft Azure Translator Text
  • Mistral AI
  • ModernMT
  • OpenAI ChatGPT

Installation

npm install mtengines

Note: The library requires Node.js 24 or newer to ensure the built-in fetch API is available at runtime.

Examples

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();

QwenTranslator, ChatGPTTranslator, AnthropicTranslator, MistralTranslator and GeminiTranslator need that you either indicate the model to use when creating the instance, or set the model to use by calling the setModel() method like in the following example:

import { ChatGPTTranslator } from "mtengines";
class TestChatGPT {

    constructor() {
        let translator: ChatGPTTranslator = new ChatGPTTranslator('yourApiKey');
        translator.setModel("gpt-4");
        translator.setSourceLanguage("en");
        translator.setTargetLanguage("fr");
         translator.translate("Hello World").then((result: string) => {
            console.log(result);
        }, (error: any) => {
            console.error(error);
        });
    }
}

new TestChatGPT();

You can get a list of models supported by QwenTranslator, ChatGPTTranslator, AnthropicTranslator, MistralTranslator and GeminiTranslator by calling the getAvailableModels() method:

import { AnthropicTranslator } from "mtengines";
class TestModels {   

    constructor() {
        let claude: AnthropicTranslator = new AnthropicTranslator('yourApiKey');
        claude.getAvailableModels().then((models: string[][]) => {
            console.log('Claude available models:');
            console.log(models);
        }, (error) => {
            console.error(error);
        });
    }
}
new TestModels();

Expected output:

Claude available models:
[
  [ 'claude-opus-4-5-20251101', 'Claude Opus 4.5' ],
  [ 'claude-haiku-4-5-20251001', 'Claude Haiku 4.5' ],
  [ 'claude-sonnet-4-5-20250929', 'Claude Sonnet 4.5' ],
  [ 'claude-opus-4-1-20250805', 'Claude Opus 4.1' ],
  [ 'claude-opus-4-20250514', 'Claude Opus 4' ],
  [ 'claude-sonnet-4-20250514', 'Claude Sonnet 4' ],
  [ 'claude-3-7-sonnet-20250219', 'Claude Sonnet 3.7' ],
  [ 'claude-3-5-haiku-20241022', 'Claude Haiku 3.5' ],
  [ 'claude-3-haiku-20240307', 'Claude Haiku 3' ],
  [ 'claude-3-opus-20240229', 'Claude Opus 3' ]
]

Note: Only QwenTranslator has a set of preconfigured models that depend on the selected working region, for all other AI-based engines the list of available models is retrieved at runtime.