Skip to content

WebCimes/gettext.js-po-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gettext.js-po-loader

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)

Require

This extension require the gettext.js extension from Guillaume Potier https://github.com/guillaumepotier/gettext.js

Installation

Use the npm package manager to install gettext.js-po-loader.

npm install gettext.js-po-loader --save-dev

Usage

Create loader in webpack config:

module: {
	rules: [
		{
			test: /\.po$/i,
			type: 'json',
			loader: 'gettext.js-po-loader',
		},
	],
},

Import the po file directly from your javascript file:

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"));

And then create a bundle with webpack.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published