0.9.0 • Published 12 years ago
grunt-merge-locale v0.9.0
grunt-merge-json
Grunt Task for Merging Multiple JSON Files
Getting Started
This plugin requires Grunt ~0.4.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-merge-locale --save-devOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-merge-locale');Task Options
replacer: (defaultnull) the replacer argument forJSON.stringify()(second argument).space: (defaulttrue) the space argument forJSON.stringify()(third argument).includeFilename: (defaulttrue) add the file name as the parent node in the json file when merging the contents of the source filedestFileName: (defaultrb) file name of the destination filedestFileExt: (defaultjson) file extension of the resulting locale file
Merge JSON Task
Run this task with the grunt merge-local command.
Task targets, files and options may be specified according to the Grunt Configuring tasks guide.
Usage Example
Assuming we have the following types of source JSON files:
src/locale/en/foo.json:
{
"title": "The Foo",
"name": "A wonderful component"
}src/locale/en/bar.json:
{
"title": "The Bar",
"name": "An even more wonderful component"
}Assuming we want to generate the following destination JSON file:
dest/locale/en/rb.json:
{
"foo": {
"title": "The Foo",
"name": "A wonderful component"
},
"bar": {
"title": "The Bar",
"name": "An even more wonderful component"
}
}Grunt Config
grunt.initConfig({
"merge-locale": {
options:{
includeFilename: true
},
dist: {
srcDir: 'src/locales/',
dest: 'dest/locales/'
}
}
});0.9.0
12 years ago