-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathtovdf.js
56 lines (46 loc) · 1.13 KB
/
tovdf.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
47
48
49
50
51
52
53
54
55
56
const yaml = require('js-yaml')
const fs = require('fs')
const path = require('path')
const langMatch = {
cs: 'czech',
de: 'german',
en: 'english',
es: 'spanish',
fr: 'french',
it: 'italian',
ja: 'japanese',
ko: 'korean',
nl: 'dutch',
pl: 'polish',
pt: 'portuguese',
'pt-br': 'brazilian',
ru: 'russian',
tr: 'turkish',
th: 'thai',
uk: 'ukrainian',
zh: 'schinese'
}
const language_directory = path.resolve('achievements')
const encoding = {
encoding: 'utf-8'
}
console.log('"lang" {')
const files = fs.readdirSync(language_directory)
files.map((filename) => {
console.error(`Reading ${filename}`)
let filepath = path.resolve(language_directory, filename)
let language = path.basename(filename, '.yml')
let translation = yaml.load(fs.readFileSync(filepath, encoding))
console.log(` "${langMatch[language]}" {
"Tokens" {`)
Object.keys(translation[language]).forEach((key) => {
let value = translation[language][key]
if (/.*\n$/.test(value)) {
value = value.slice(0, value.length - 1)
}
console.log(` "${key}" "${value}"`)
})
console.log(` }
}`)
})
console.log(`}`)