-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
43 lines (34 loc) · 1.23 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*!
* @package olympus-artemis-backend-theme
* @author Achraf Chouk <[email protected]>
* @since 0.0.1
*/
'use strict';
module.exports = function(grunt) {
var opts = grunt.file.readJSON('tasks/options.json'),
files = grunt.file.expand({filter: "isFile"}, opts.phpfiles),
srcpath = opts.paths.src + '/' + opts.paths.i18n,
jsons = grunt.file.expand({filter: "isFile"}, srcpath + '/*.json');
// measures the time each task takes
require('time-grunt')(grunt);
// read all files and generate PO files
jsons.forEach(function (jsonfile) {
var name = jsonfile.split('/').pop().split('.')[0],
json = grunt.file.readJSON(srcpath + '/' + name + '.json');
var text = "";
for (var item in json) {
text += 'msgid "' + item + '"' + "\r\n";
text += 'msgstr "' + json[item].replace(/\"/g, '\\"') + '"' + "\r\n";
text += "\r\n";
}
grunt.file.write(opts.paths.i18n + '/' + opts.textdomain + '-' + name + '.po', text);
if ("en_US" === name) {
grunt.file.write(opts.paths.i18n + '/' + opts.textdomain + '-default.po', text);
}
});
// load grunt config
require('load-grunt-config')(grunt, {
configPath: require('path').join(__dirname, 'tasks'),
config: opts
});
};