i18n-js is a lightweight JavaScript/TypeScript library for internationalization (i18n) and localization (l10n). Version 4.5.3 is stable with regular updates. It provides interpolation, pluralization, and date/number formatting. Unlike react-i18next or i18next, i18n-js is framework-agnostic and simple, focusing on minimal overhead and ease of use. It supports CommonJS and ESM, has TypeScript definitions built-in, and works in both Node.js and browser environments. Key differentiators are its small size (~5 KB gzipped), no dependencies beyond the locale data, and a familiar Rails-style I18n API.
npm install i18n-jsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup of translations, locale switching, interpolation, and pluralization using the I18n.t() method.
Replace direct I18n.t() calls with I18n.t() after importing the default export. Update imports from 'i18n-js' to import I18n from 'i18n-js'.
Ensure all pluralization keys include at least 'one' and 'other' per locale.
Replace I18n.defaultLocale with I18n.defaultLocale property (no prototype).
Replace I18n.locales with I18n.availableLocales.
Always set I18n.translations for each locale you intend to use. Use I18n.fallbacks or implement custom fallback logic.
Avoid keys with dots inside them, or use I18n.t('inbox.one') with proper nested objects.Use consistent variable names in translation strings and the options object.
Use const I18n = require('i18n-js'); not require('i18n-js').defaultUpgrade to v4, import I18n from 'i18n-js' and use I18n.t() as method.
Run npm install i18n-js
Ensure I18n.translations is set before calling I18n.t()
Import correctly: import I18n from 'i18n-js'