Grunt plugin for Globalize
This plugin requires Grunt ~1.1.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-globalize --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-globalize');
In your project's Gruntfile, add a section named globalize
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
globalize: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific options go here.
},
},
});
Type: Array
Default value: []
An array of locales to generate parsers and formatters for.
Type: String
Default value: './output'
The destination directory for the compiled formatters.
Type: String
Default value: 'compiled'
The base name of the compiled formatter output file. The full filename is
generated as [options.destFile].[locale].js
.
Type: Array
Default value: []
A list of all supported currencies. This will be used to generate one currency formatter for each combination of currency code and options.
Type: Array
Default value: []
An array of options objects to be passed to the currencyFormatter
function.
Note, pass undefined
as a value if you create the formatter without parameters.
Type: Array
Default value: []
An array of options objects to be passed to the dateFormatter
function.
Note, pass undefined
as a value if you create the formatter without parameters.
Type: Array
Default value: []
An array of options objects to be passed to the numberFormatter
function.
Note, pass undefined
as a value if you create the formatter without parameters.
In this example, formatters are generated for en-US
and fr-FR
locales.
The currencyFormatter
function takes no options, while dateFormatter
and
numberFormatter
utilize both the default options and one customized option each.
The compiled output files go to ./tmp/custom_options/compiled.en-US.js
and
./tmp/custom_options/compiled.fr-FR.js
.
grunt.initConfig({
globalize: {
custom_options: {
options: {
locales: ['en-US', 'fr-FR'],
destDir: './tmp/custom_options/',
destFile: 'compiled',
currencyOptions: [ undefined ],
dateOptions: [ undefined, { date: 'short' } ],
numberOptions: [ undefined, { maximumFractionDigits: 1 } ]
}
}
}
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
v0.0.1 Initial Release