-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathstring.js
46 lines (38 loc) · 968 Bytes
/
string.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
44
45
46
const fs = require('fs');
function discardGarbage(lines) {
while (lines.length && ![
'A4Q2ExpansionSuccessTyrael',
'Cutthroat1',
'WarrivAct1IntroGossip1',
].includes(lines[0])) {
lines.shift();
}
return lines;
}
[
'chi',
'deu',
'eng',
'esp',
'fra',
'ita',
'kor',
'pol',
].forEach(lang => {
let strings = {};
[
'string.tbl',
'expansionstring.tbl',
'patchstring.tbl',
].forEach(name => {
console.log('Processing: ', lang, name);
let lines = discardGarbage(fs.readFileSync('tbl/' + lang + '/' + name).toString().split('\0'));
while (lines.length) {
let key = lines.shift(), str = lines.shift();
if (key.trim().length) {
strings[key.trim()] = str;
}
}
});
fs.writeFileSync('./json/localestrings-' + lang + '.json', JSON.stringify(strings, null, ' '));
});