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

@lite-translator/core

v0.2.1

Published

Privacy-friendly, local, offline-capable translation core API for the browser.

Readme

@lite-translator/core

npm version License: MIT

Dependency-free, privacy-friendly translation API for the browser. Translation text never leaves the user's device — no cloud, no servers.

Part of lite-translator — a small, offline-capable browser translation library. This package provides the engine-independent core API. Pair it with @lite-translator/engine-onnx for local ONNX/Transformers.js inference.

Install

npm install @lite-translator/core @lite-translator/engine-onnx

Quickstart

import { createTranslator } from "@lite-translator/core";
import { createOnnxEngine } from "@lite-translator/engine-onnx";

const translator = await createTranslator({
  from: "de",
  to: "en",
  engines: [createOnnxEngine()],
});

const result = await translator.translate("Hallo Welt");
console.log(result.text);
await translator.dispose();

Features

Batch translation

Translate many texts in a single inference call — one tokenization, encoder and decoder pass for the whole batch instead of N roundtrips.

const results = await translator.translateBatch([
  "Hallo Welt",
  "Guten Morgen",
  "Wie geht es dir?",
]);
// results[i].text corresponds to input i (order preserved, empty strings kept)

i18n-style translation

Register UI strings across components with t(key, text), then translate all of them in one translateAll() call — one inference pass, no race conditions.

const t = translator.t();

// Component A
t("header.title", "Willkommen"); // registers, returns "Willkommen"
t("header.subtitle", "Bitte wählen");

// Component B
t("footer.button", "Bestätigen");

// One click — one inference call for all registered strings
await translator.translateAll();

t("header.title"); // → "Welcome" (translated)
t("footer.button"); // → "Confirm" (translated)

The store is reactive: frameworks bind via subscribe() / snapshot() and re-render automatically. Identical values are deduplicated before inference. → Full guide

Live translation

Incremental translation for chat or speech-to-text. Input is segmented at sentence boundaries; completed sentences are cached and only the still-growing tail is re-translated.

const live = translator.createLiveSession({ debounce: 250 });

live.on("translation", (e) => {
  console.log(e.text); // full translation
  console.log(e.partial); // still-growing tail
});

live.update("Hallo wie geht");

→ Full guide

Debug output

Structured lifecycle and timing events via an opt-in onDebug callback — zero overhead when absent.

const translator = await createTranslator({
  from: "de",
  to: "en",
  engines: [engine],
  onDebug: (e) => console.debug(`[${e.type}]`, e),
});

await translator.preload();
// [load-start] { pair: { from: "de", to: "en" }, ... }
// [load-done]  { durationMs: 1234, ... }

await translator.translate("Hallo Welt");
// [translate-start] { inputLength: 10, ... }
// [translate-done]  { durationMs: 45, outputLength: 11, ... }

→ Full guide

Capabilities

Inspect the engine's resolved device, dtype, and model after load.

await translator.preload();
console.log(translator.capabilities());
// { engine: "onnx", device: "wasm", dtype: "bnb4", modelId: "onnx-community/opus-mt-de-en" }

Cache management

Remove a model from the browser's Cache Storage to free disk space or force a re-download.

await translator.preload();
console.log(await translator.isCached()); // true
await translator.removeModel();
console.log(await translator.isCached()); // false

API

| Export | Description | | --- | --- | | createTranslator(options) | Creates a translator (no model download on import) | | translator.translate(text, options?) | Translates text; options.signal for AbortSignal cancellation | | translator.translateBatch(texts, options?) | Translates multiple texts in one call (order preserved) | | translator.preload() | Explicitly preloads the model | | translator.t() | Returns bound t(key, text?) for i18n-style registration | | translator.translateAll(options?) | Translates all t()-registered strings in one translateBatch() and notifies store subscribers once | | translator.createLiveSession(options?) | Creates a LiveSession for incremental live translation | | translator.capabilities() | Returns resolved engine capabilities (device, dtype, model info) | | translator.removeModel() | Removes cached model files from Cache Storage | | translator.store() | Reactive TranslationStore backing t() (lazy, undefined before first t()) | | translator.isReady() | Model loaded and ready | | translator.isCached() | Model present in local cache (offline-capable) | | translator.dispose() | Frees resources | | TranslatorPool | Manages translators by language pair with LRU eviction (maxSize) | | formatTranslatorError(err) | Formats any error into a consistent human-readable string | | isTranslatorError(err) | Type guard for TranslatorError | | withBatchFallback(engine) | Wraps an engine without translateBatch with a sequential fallback |

Links