po-gettext-loader

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

A webpack loader that converts GNU gettext PO files to JSON using gettext-parser. Version 1.0.0 is the latest stable release, published once. It integrates into webpack build pipelines for i18n workflows, outputting JSON that can be further processed by json-loader. Simpler than using gettext tools directly, but has no active maintenance or updates. Differentiates by offering a direct Webpack integration without additional configuration.

error Module parse failed: Unexpected token (1:1) You may need an appropriate loader to handle this file type.
cause Missing json-loader after po-gettext-loader
fix
Add json-loader to the rule: { test: /\.po$/, use: [ 'json-loader', 'po-gettext-loader' ] }
error Error: Cannot find module 'gettext-parser'
cause Missing peer dependency gettext-parser
fix
Run npm install gettext-parser --save-dev
gotcha Requires json-loader to be chained after po-gettext-loader, else webpack cannot handle the output
fix Add json-loader in the use array after po-gettext-loader as shown in quickstart
deprecated Package is not actively maintained; last publish in 2018
fix Consider using @formatjs/intl-gettext-loader or writing a custom loader
gotcha Loader output is a JSON string, not a JavaScript object; must be used with json-loader or similar
fix Chain with json-loader as shown
npm install po-gettext-loader
yarn add po-gettext-loader
pnpm add po-gettext-loader

Shows webpack configuration to load .po files, converting them to JSON then bundling.

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.po$/,
        use: [
          { loader: 'json-loader' },
          { loader: 'po-gettext-loader' }
        ]
      }
    ]
  }
};
// Then import .po files:
import translations from './messages.po';