-
Notifications
You must be signed in to change notification settings - Fork 1
/
match-locales.js
42 lines (40 loc) · 1013 Bytes
/
match-locales.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
console.log("Matching... \n");
let locales = [
require('./assets/locales/fr.json'),
require('./assets/locales/en.json')
];
let keys = [];
const all_keys = require('all-object-keys');
locales.forEach((locale) => {
keys[locale._id] = all_keys(locale)
});
const colors = require('colors');
const colors_a = [
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan'
];
let errors = 0;
locales.forEach((origin_locale) => {
locales.forEach((locale) => {
let color = colors_a[Math.floor(Math.random()*colors_a.length)];
colors_a.splice(colors_a.indexOf(color), 1);
keys[origin_locale._id].forEach((item) => {
if (keys[locale._id].indexOf(item) === -1) {
console.log(colors[color](item + " in ") + colors.bold(locale._id));
errors++
}
})
});
console.log("");
});
if (errors === 0) {
console.log(colors.bold(colors.green('No errors')));
console.log("");
} else {
console.log(colors.bold(colors.red(`Found ${errors} error(s)`)));
console.log("");
}