jQuery i18n Loader
A loader for Webpack that injects locale files for use with wikimedia/jquery.i18n.
Motivation
There didn't seem to be any loaders that supported the jQuery.i18n internationalization library, so I decided I would create one myself. I plan to soon fork wikimedia/jquery.i18n in the near future and implement support for module systems such as Webpack.
Example
Below is a simple Webpack configuration file (webpack.config.js).
var Path = ; moduleexports = entry: "./app/main.js" output: filename: "bundle.js" module: loaders: test: /\.locale.json$/ loader: "jquery-i18n" ;
Next we need to create a locale file (en.locale.json).
Lastly, we'll require jQuery.i18n and the locale file.
// require jQuery and attach it to the window (eww).window$ = windowjQuery = ; // Since there is a number of files, we'll make use of require.context to make it more readable.var req = require; // Quick and dirty way to require all the necessary files. We do it this way to maintain require order.var files = "js" "messagestore" "fallbacks" "parser" "emitter" "language";files; // Require the locale file.; // Alert the user to show it's working.;;