-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtovdf.js
47 lines (37 loc) · 1008 Bytes
/
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
const yaml = require('js-yaml')
const fs = require('fs')
const path = require('path')
const langMatch = {
de: 'german',
en: 'english',
es: 'spanish',
it: 'italian',
pt: 'portuguese',
fr: 'french',
ru: 'russian',
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(`}`)