opensourcetypescripti18nnpm
i18n Modern
Framework-agnostic localization module compatible with Node.js and any frontend framework — Vue, Svelte, Solid.js, and more.
i18n Modern is a module for managing localization both on the backend with Node.js and on the frontend with any framework. Its design is framework-agnostic, integrating with reactive systems in Vue, Svelte, Solid.js, and others through custom getter/setter functions.
Key features
- Dot notation keys: access nested values with paths like
home.section1.title. - Key assertions: conditional logic in translations to handle plurals and ranges without extra code.
- Variable substitution: dynamic value interpolation in both keys and text.
- Modern and legacy API: new configuration-based API alongside compatibility with the previous API.
Installation
npm install i18n_modern
Basic usage
import { I18nModern } from "i18n_modern";
const i18n = new I18nModern({
defaultLocale: "es-MX",
locales: { "es-MX": { greeting: "Hola [name]" } },
});
i18n.get("greeting", { locale: "es-MX", values: { name: "Uriel" } });
// → "Hola Uriel"