gettext.js extension to load po file with webpack, based on po2json wrapper from Guillaume Potier (https://github.com/guillaumepotier/gettext.js/blob/master/bin/po2json)
This extension require the gettext.js extension from Guillaume Potier https://github.com/guillaumepotier/gettext.js
Use the npm package manager to install gettext.js-po-loader.
npm install gettext.js-po-loader --save-dev
module: {
rules: [
{
test: /\.po$/i,
type: 'json',
loader: 'gettext.js-po-loader',
},
],
},
import messages from '../lang/fr/LC_MESSAGES/default.po';
import gettext from "../../node_modules/gettext.js/dist/gettext.cjs.js";
const i18n = gettext();
i18n.loadJSON(messages);
console.log(i18n.__("Hello"));