Converts gettext .po, .pot, and .mo files into messageformat-compatible JSON. Version 0.4.0, released as a stable library with no further updates expected. It uses gettext-parser under the hood and provides functions parsePo and parseMo that return headers, a plural function, and translations object. The plural function can be derived from the Plural-Forms header or provided manually. Key differentiator: bridges the gap between gettext tooling and messageformat-based internationalization in JavaScript, with support for plural forms and context.
npm install gettext-to-messageformatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Parses a .po file with plural forms and uses messageformat to format a pluralized message.
Use `sort` option instead of `sortByMsgId`.
Access header keys with canonical case (e.g., 'Language' instead of 'language').
Upgrade Node.js to >=6.0.
Check if pluralFunction is null and provide a fallback if needed.
Run `npm install gettext-to-messageformat` and ensure the import path is correct.
Use `const { parsePo } = require('gettext-to-messageformat')` or `import { parsePo } from 'gettext-to-messageformat'`.Ensure the input is a valid .po or .mo file content as a string or Buffer.