forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-translation.js
38 lines (28 loc) · 896 Bytes
/
update-translation.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
/* eslint-disable */
const fs = require('fs');
const process = require('process');
const traverse = require('traverse');
const mainLang = require('./main.json');
const [ targetLangFile ] = process.argv.slice(-1);
if (!targetLangFile) {
console.log('No target language file specified');
process.exit(1);
}
const targetLang = require(`./${targetLangFile}`);
const paths = traverse(mainLang).reduce(function(acc, item) {
if (this.isLeaf) {
acc.push(this.path);
}
return acc;
}, []);
const result = {};
for (const path of paths) {
if (traverse(targetLang).has(path)) {
traverse(result).set(path, traverse(targetLang).get(path));
} else {
//console.log(`${path.join('.')} is missing`);
traverse(result).set(path, '');
}
}
const data = JSON.stringify(result, undefined, 4);
fs.writeFileSync(`./${targetLangFile}`, data + "\n");