forked from ricktu288/ray-optics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.js
27 lines (23 loc) · 873 Bytes
/
sync.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
// Run this script with node.js whenever some new items are added into en.js
locale_name = ['en', 'zh-TW', 'zh-CN', 'ru', 'nl', 'fr', 'de', 'pl', 'LOCALE_ID'];
locale_files = ['en.js', 'zh_TW.js', 'zh_CN.js', 'ru.js', 'nl.js', 'fr.js', 'de.js', 'pl.js', 'template.js'];
fs = require('fs');
var locales = {};
for (var i in locale_name) {
eval(fs.readFileSync(locale_files[i]).toString());
}
var locales_new = {};
for (var i in locale_name) {
var locale = {};
for (var key in locales['en']) {
if (locales[locale_name[i]][key]) {
locale[key] = locales[locale_name[i]][key];
} else {
locale[key] = {incomplete: true, message: locales['en'][key].message};
}
}
fs.writeFileSync(locale_files[i],
"if (typeof locales == 'undefined') locales = {};\n" +
"locales[\"" + locale_name[i] + "\"] = " +
JSON.stringify(locale, null, 2));
}