Skip to content
Merge localization JSON files/namespaces to a single file
Find file
Latest commit ab626ce @tomgutz updated readme
Failed to load latest commit information.
tasks Initial checkin for the the tool
.npmignore Initial checkin for the the tool
Gruntfile.js Initial checkin for the the tool Initial checkin for the the tool
Makefile updated readme
package.json Initial checkin for the the tool


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-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:


Task Options

  • replacer: (default null) the replacer argument for JSON.stringify() (second argument).
  • space: (default true) the space argument for JSON.stringify() (third argument).
  • includeFilename: (default true) add the file name as the parent node in the json file when merging the contents of the source file
  • destFileName: (default rb) file name of the destination file
  • destFileExt: (default json) 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

    "merge-locale": {
          includeFilename: true
        dist: {
           srcDir: 'src/locales/',
           dest: 'dest/locales/'
Something went wrong with that request. Please try again.