globalize-config-loader

0.3.0 • Public • Published

Globalize-config-loader is a loader for globalize-config-compiler. It will convert a configuration object (e.g. a json file loaded with json-loader) into a function that returns a new Globalize instance.

Installation

Install the loader, globalize, and cldr-data:

npm install --save-dev globalize-config-loader globalize cldr-data

Usage

Create a function such as this in your code:

function getGlobalize(locale, callback) {
    require('globalize-config-loader!json-loader!./locale/config.json')(locale, function(initFn) {
        initFn(callback);
    });
}

callback will be called with a single parameter, a Globalize instance set to locale with the formatters and parsers in config.json.

By default, the code is split into separate chunks, one for the globalize runtime, and one for the locale-specific data for each locale. These chunks are loaded when first needed. You can add sync=true to the loader's query string to disable code splitting, but note that this will compile all the locales in the configuration into the calling chunk:

require('globalize-config?sync=true!json!./locale/config.json')(locale, function(initFn) { ... });

Dependents (0)

Package Sidebar

Install

npm i globalize-config-loader

Weekly Downloads

0

Version

0.3.0

License

MIT

Last publish

Collaborators

  • nkovacs