Browser-side GNU gettext implementation for internationalization (i18n). Current stable version is 2.1.1. Provides a `gettext`-like interface in the browser, compiles MO files to JavaScript, includes a webpack loader for MO files, and supports plural forms with `ngettext`. Key differentiators: lightweight, browser-focused, integrates with webpack, and offers both runtime API and pre-compilation. Compared to i18next or Polyglot, gettext.js is closer to the GNU gettext workflow and simpler for projects already using MO files. Release cadence: occasional maintenance updates, as last release was several years ago.
npm install gettextjsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup: import named exports, set_catalog with translations, and use gettext/ngettext.
Always call set_catalog with a valid catalog object (locale -> { message: translation }) at initialization.Use the webpack loader or include a precompiled catalog via set_catalog.
Use the provided webpack loader for `.mo` files, or compile the `.mo` to a JS file using the CLI (`gettextjs compile input.mo output.js`) and then import that file.
Use named imports: `import { gettext as _, ngettext, set_catalog } from 'gettextjs'`.Change `import gettext from 'gettextjs'` to `import { gettext as _ } from 'gettextjs'`.Run `npm install gettextjs` and ensure the import path is correct.
Call `set_catalog({ 'en': { 'key': 'value' } })` with a valid catalog object.Ensure the catalog includes the exact string key and that the locale matches. Use `set_catalog({ locale: { msgid: msgstr } })`.No dependency data recorded yet.