The best Grunt plugin ever.
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');
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.
},
},
});
Type: String
Default value: process.cwd()
if you need put your translation excel files somewhere in file system, not in process.cwd
Type: Boolean
Default value: false
If set to true will parse values into integer or boolean when they are strings with boolean or integer shape.
Type: String
Default value: true
For beautify output JSON in file
Type: boolean
Default value: false
For writting language entries into separated json files
Type: Boolean
Default value: false
If this value is set to true, then the json object will be created based on columns of the excel file. This means that the output will be an array of objects, in which, each object will have as key the first row, and as value the text inside the next rows.
Type: Function
Function that loads the json object with the data of the row in the excel file. By default:
set: function (resultJsonObject, columnName, sheetName, key, value) {
if (!resultJsonObject.hasOwnProperty(columnName)) {
resultJsonObject[columnName] = {};
}
resultJsonObject[columnName][key] = value;
}
Type: Function
If the option 'isColumnOriented' is set to true, this function will be called when loading the column data. By default:
setColumn: function (columnData, columnName, sheetName, key, value) {
var row = {};
row[ columnName ] = value;
return row;
}
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'
}],
}
},
});
First row is a column names. First column of each row will be a key name.
Example: (cell colors is not matter)
MIT
If you have any problems, catch the bug or have any suggestion - please find an existing issue or create new
Do that! How to contribute open-source projects
run the tests by following command
$ npm test