message-format-loader
Write default messages inline. Transpile translations with webpack.

a webpack loader for message-format
install
$ npm install message-format-loader --save-dev
api
messageFormat
in your webpack.config.js
These are the same as options that are passed to format.setup()
See message-format-inline for more information
module.exports = [ "en", "pt" ].map(function(locale) {
entry: "path/to/entry.js",
output: {
path: "path/to/output/",
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.js$/,
loader: "message-format"
}
]
},
messageFormat: {
functionName: 'format',
locale: locale,
translate: function(pattern, locales) {
return require('path/to/translations/' + locale + '.json')[pattern];
},
translations: {
pt: { ... },
de: { ... }
},
keyType: 'underscored_crc32'
}
});
in your js file:
var format = require('message-format-inline')
format('Welcome {name}!', { name:'Bob' })
License
This software is free to use under the MIT license.
See the LICENSE-MIT file for license text and copyright information.