Registry / web-framework / po-loader

po-loader

JSON →
library0.7.0jsnpmunverified

Webpack loader for translating .po files (GNU gettext) into JSON. Uses po2json under the hood, supports mozilla/nunjucks, Jed, and other formats. Version 0.7.0 (latest, 2017). Sync and async usage; often paired with Jed for i18n. No updates since 2017, works with webpack v1 only. Not actively maintained; consider @lingui/webpack or i18n-webpack-plugin.

npm install po-loader
INSTALL
IMPORT
SIG · PO-LOADER
P
po-loader
web-frameworkjavascriptv0.7.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

po-loader
import messages from './locale.po';
require('./locale.po');
Loader applies automatically if configured in webpack.config
po-loader
var messages = require('json!po!./locale.po');
var messages = require('po-loader!./locale.po');
Must be chained with json loader (or raw loader if you want JSON)
po-loader
import localePromise from './locale.po'; // then call .then() or await
import locale from './locale.po'; // missing async loading
For async usage, use dynamic import(/* webpackChunkName: 'locale' */ './locale.po')

Webpack config to load .po files with po-loader and json-loader, then async import a .po file and use Jed.

// webpack.config.js { test: /\.po$/, loader: 'json!po', exclude: /node_modules/ } // entry.js import Jed from 'jed'; async function init() { const localeData = await import('./locale/en_US/LC_MESSAGES/messages.po'); const i18n = new Jed(localeData); console.log(i18n.gettext('Hello')); } init();
Debug
Known issues
breakingpo-loader requires webpack 1.x only; does not work with webpack 2+ modular loaders. Use json!po syntax which breaks in webpack 2+
fix
Upgrade to webpack 1 or switch to a modern i18n webpack plugin like @lingui/webpack
affects: >=0.5.0
deprecatedpo2json peer dependency must be >=1.0.0-beta-3, but that version may have breaking changes. Always pin exact version.
fix
Use po2json@1.0.0-beta-3 exactly in package.json
affects: >=0.7.0
gotchaRequiring .po files without the json loader prefix (json!po) will output raw po2json format, not run through po-loader
fix
Always use json!po prefix in require or configure in webpack.config with json!po loader string
affects: >=0.0.1
breakingDynamic import path must match the regex for webpack to create separate bundles; otherwise returns undefined
fix
Use import(`${LOCALE_ROOT}/${locale}/LC_MESSAGES/messages.po`) with LOCALE_ROOT as a constant string
affects: >=0.5.0
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
No loader configured for .po files in webpack
fix
Add po-loader and json-loader to webpack config: { test: /\.po$/, loader: 'json!po' }
Cannot find module 'po2json'
Missing peer dependency po2json
fix
npm install po2json@>=1.0.0-beta-3 --save-dev or --save
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
po2jsonrequiredPeer dependency for parsing .po files; must be >=1.0.0-beta-3
Agent activity
4 hits · last 30 days
node
4
Resources