intor-translator
v1.5.0
Published
The Intor translation engine
Maintainers
Readme
Features
- Modular Pipeline – A pluggable, hook-driven flow for any translation logic.
- Typed Autocomplete – Inferred keys and locales with precise, reliable completion.
- Framework-Agnostic – A lightweight engine that runs anywhere in JavaScript.
Installation
# npm
npm install intor-translator
# yarn
yarn add intor-translator
# pnpm
pnpm add intor-translatorQuick Start
import { Translator } from "intor-translator";
const messages = {
en: {
hello: "Hello World",
greeting: "Hello, {name}!", // Use curly braces for replacements
},
};
// Create a translator instance
const translator = new Translator({ messages, locale: "en" });
// Use the translator
translator.t("hello"); // -> Hello World
translator.t("greeting", { name: "John doe" }); // -> Hello, John doe!Handlers & Hooks
Intor Translator runs on an explicit, hook-driven pipeline.
Ordered pipeline:
resolveLocales → findMessage → loading → missing → format → interpolate
Handlers
Handlers override specific pipeline stages:
- loading
- missing
- formatting
Hooks
Hooks participate in the ordered pipeline and control how the translation process executes.
They allow external logic to extend or adjust the pipeline behavior.
For more advanced usage, see the full examples. View examples ↗
See full benchmark details: bench ↗
