grunt-excel-vocabulary

1.0.1 • Public • Published

npm npm Dependency Status devDependency Status Build Status Coverage Status

grunt-excel-vocabulary

Gitter

The best Grunt plugin ever.

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-excel-vocabulary --save

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

grunt.loadNpmTasks('grunt-excel-vocabulary');

The "excel_vocabulary" task

Overview

In your project's Gruntfile, add a section named excel_vocabulary to the data object passed into grunt.initConfig().

grunt.initConfig({
  excel_vocabulary: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.root

Type: String Default value: process.cwd()

if you need put your translation excel files somewhere in file system, not in process.cwd

options.beautify

Type: String Default value: true

For beautify output JSON in file

options.keepEveryRowInFile

Type: boolean Default value: false

For writting language entries into separated json files

options.set

Type: Function

By default:

set: function (resultJsonObject, columnName, sheetName, key, value) {
    if (!resultJsonObject.hasOwnProperty(columnName)) {
        resultJsonObject[columnName] = {};
    }
 
    resultJsonObject[columnName][key] = value;
}

Usage Examples

Default Options

In this example, the default options are used to do something with whatever. So if the testing file has the content Testing and the 123 file had the content 1 2 3, the generated result would be Testing, 1 2 3.

grunt.initConfig({
  excel_vocabulary: {
    first: {
      options: {
        beautify: false
      }
      files: [
        { 'translations.json': 'translation.xlsx' },
        { src: 'translation.xlsx', dest: 'translation.json' }
      ],
    },
    second: {
      files: [{
        expand: true,
        cwd: 'path/to/source/dir',
        dest: 'path/to/build/dir',
        src: [
          '**/*.xlsx'
        ],
        ext: '.json'
      }],
    }
  },
});

Excel File:

First row is a column names. First column of each row will be a key name.

Example: file example (cell colors is not matter)

License

MIT

Support

If you have any problems, catch the bug or have any suggestion - please find an existing issue or create new

Contributing

Do that! How to contribute open-source projects

run the tests by following command

$ npm test

Together we can change the world!

Package Sidebar

Install

npm i grunt-excel-vocabulary

Weekly Downloads

20

Version

1.0.1

License

MIT

Last publish

Collaborators

  • alxe.master