This plugin requires Grunt.
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-extract-cldr-data --save-dev
The "extract_cldr_data" task
In your project's Gruntfile, add a section named
extract_cldr_data to the data object passed into
Each target must supply a
dest property for the file path where the generated files should be outputted to. If
dest is a directory, then a file will be generated per locale. If
dest is a
.js file, then only one file will be generated and it will contain the data for all
Default value: All CLDR locales
An array of language tag strings strings for the locales to extract data for; e.g.,
['en', 'fr', 'zh-Hant-HK', ...]
Whether or not the
pluralRuleFunction CLDR data should be extracted for each of the given
Whether or not the relative-time
fields CLDR data should be extracted for each of the given
A function that will be passed a string of serialized data for each each
Extract Plural Rule Functions
In this example, the CLDR plural rule functions for all locales will be extracted and output into a single file which wraps each locale's data in a function call:
Extract Fields and Plural Rule Functions
In this example, CLDR relative-time fields and plural rule functions for just English and French will be extracted and output into a one file per locale. Both of the locale's data is also wrapped in a function call:
locale-data/ directory will contain two files:
fr.js. This is because the hierarchy in the language tags is leveraged to de-duplicate data at the language level.
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
1.0.0: Initial release.
1.0.1: Update cldr package to fix issue with plural rule functions.
1.1.0: Update and lock-down cldr package to latest.
2.0.0: Refactored to use formatjs-extract-cldr-data.
2.1.0: Upgrade to
3.0.0: Upgrade to
4.0.0: Upgrade to
4.1.0: Upgrade to
This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.