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

a webpack loader for format-message
install
$ npm install format-message-loader --save-dev
api
formatMessage
in your webpack.config.js
These are the same as options that are passed to formatMessage.setup()
See format-message for more information
module.exports = [ "en", "pt", "de" ].map(function(locale) {
entry: "path/to/entry.js",
output: {
path: "path/to/output/",
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.js$/,
loader: "message-format"
}
]
},
formatMessage: {
functionName: "formatMessage",
locale: locale,
translate: function(pattern, locales) {
return require("path/to/translations/" + locale + ".json")[pattern];
},
translations: {
pt: { ... },
de: { ... }
},
keyType: "underscored_crc32",
missingTranslation: "warning",
missingReplacement: "!!NOT TRANSLATED!!"
}
});
in your js file:
var formatMessage = require('format-message')
formatMessage('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.