🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

message-format-loader

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

message-format-loader

Write default messages inline. Transpile translations with webpack.

Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

message-format-loader

Write default messages inline. Transpile translations with webpack.

npm Version Dependency Status

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', // identifier of function to inline
		locale: locale, // default locale
		translate: function(pattern, locales) {
			// from call format(pattern, args, locales)
			// if no locales were passed to format, locales will be the default locale (specified above)
			return require('path/to/translations/' + locale + '.json')[pattern];
		},
		translations: { // or rather than a translate function, lookup from an object
			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.

Keywords

i18n

FAQs

Package last updated on 11 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts