0.3.0 • Published 8 years ago

grunt-custom-bundle-checker v0.3.0

Weekly downloads
3
License
-
Repository
github
Last release
8 years ago

grunt-custom-bundle-checker

Compare bundle files (.json files) for localization and fill in the missing translation with string in English bundle file. Existing bundle files with specified language will be overwritten.

Getting Started

This plugin requires Grunt ~0.4.5

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-custom-bundle-checker --save-dev

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

grunt.loadNpmTasks('grunt-custom-bundle-checker');

The "custom_bundle_checker" task

Overview

In your project's Gruntfile, add a section named custom_bundle_checker to the data object passed into grunt.initConfig(). DO NOT PUT 'dest' IN YOUR CONFIGURATION.

Translated bundle files should be put in the same directory as English bundle files and they should be named by adding _ + language, and they should be .json files.

For example, if English bundle file has name "bundle.json", then the Japanese bundle file in the same directory should be "bundle_ja.json"

grunt.initConfig({
  custom_bundle_checker: {
    your_subtask_name: {
      options: {
        // Task-specific options go here.
      },
      src: //src file paths go here
    },
  },
});

Options

options.destLang

Type: String Array Default value: '[]'

A array of strings specify which languages are used for bundle files, this will determine files with what suffix will be checked.

Usage Examples

Default Options

In this example, the default options will do nothing, since no destLang is specified, therefore no bundle file other than English to be compared to English bundle file

grunt.initConfig({
  custom_bundle_checker: {
    main: {
      options: {},
      src: []
    }
  },
});

Custom Options

In this example, 'ja' is set in options.destLang, then translation bundle file (e.g. bundle_ja.json) for Japanese will be checked against English. If bundle_ja.json is missing translation for "c", after running the task, the value for "c" in English bundle file will be added to bundle_ja.json

grunt.initConfig({
  custom_bundle_checker: {
    options: {
      destLang: ['ja']
    },
    src: ['path/to/bundle/files']
  },
});

Example:

Before running task:

bundle.json

{
  "a": "value1",
  "b": "value2",
  "c": "value3"
}

bundle_ja.json

{
  "a": "XXX",
  "b": "YYY"
}

After running task:

bundle.json

{
  "a": "value1",
  "b": "value2",
  "c": "value3"
}

bundle_ja.json

{
  "a": "XXX",
  "b": "YYY",
  "c": "value3"
}

Contributing

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.

Release History

(Nothing yet)

0.3.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago