1 import * as xliff12ToJs from 'xliff/xliff12ToJs'
2 import { readFileSync, writeFile } from 'fs'
3 import { join } from 'path'
6 const playerSource = join(__dirname, '../../../client/src/locale/target/player_fr.xml')
7 const playerTarget = join(__dirname, '../../../client/src/locale/target/player_fr.json')
9 // Remove the two first lines our xliff module does not like
10 let playerFile = readFileSync(playerSource).toString()
11 playerFile = removeFirstLine(playerFile)
12 playerFile = removeFirstLine(playerFile)
14 xliff12ToJs(playerFile, (err, res) => {
20 const json = createJSONString(res)
21 writeFile(playerTarget, json, err => {
31 function removeFirstLine (str: string) {
32 return str.substring(str.indexOf('\n') + 1)
35 function createJSONString (obj: any) {
37 const strings = obj.resources['']
39 Object.keys(strings).forEach(k => res[k] = strings[k].target)
41 return JSON.stringify(res)