Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

example.js

console.log(__("Hello World"));
console.log(__("Missing Text"));

webpack.config.js

var I18nPlugin = require("i18n-webpack-plugin");
module.exports = {
	plugins: [
		new I18nPlugin(
			require("./de.json") // or pass null to use defaults
		)
	]
}

I recommend to use new I18nPlugin(null) for development and write a small script that generates bundles for every language

de.json

{
	"Hello World": "Hallo Welt"
}

js/output.js

/******/ (function webpackBootstrap(modules) {
/******/ 	var installedModules = {};
/******/ 	function require(moduleId) {
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};
/******/ 		modules[moduleId].call(null, module, module.exports, require);
/******/ 		module.loaded = true;
/******/ 		return module.exports;
/******/ 	}
/******/ 	require.e = function requireEnsure(chunkId, callback) {
/******/ 		callback.call(null, require);
/******/ 	};
/******/ 	require.modules = modules;
/******/ 	require.cache = installedModules;
/******/ 	return require(0);
/******/ })({
/******/ c: "",

/***/ 0:
/*!********************!*\
  !*** ./example.js ***!
  \********************/
/***/ function(module, exports, require) {

	console.log("Hallo Welt");
	console.log("Missing Text");

/***/ }
/******/ })

Info

Uncompressed

Hash: 6dd5f9550269e46e82b8dd537732bdfa
Time: 17ms
    Asset  Size  Chunks  Chunk Names
output.js   989       0  main       
chunk    {0} output.js (main) 64
    [0] ./example.js 64 [built] {0}

ERROR in ./example.js
Missing localization: Missing Text

Minimized (uglify-js, no zip)

Hash: 6dd5f9550269e46e82b8dd537732bdfa
Time: 52ms
    Asset  Size  Chunks  Chunk Names
output.js   308       0  main       
chunk    {0} output.js (main) 64
    [0] ./example.js 64 [built] {0}

ERROR in ./example.js
Missing localization: Missing Text