var _fs = require("fs");
var _hocon = require("topsin.hocon");
var _ = require("lodash");

var bi_dir = "D:/workspace/toplinker/gitlab/topsin/topreport/src/client/modules";
var d = _fs.listDir(bi_dir, -1);
d = _.filter(d, {"name": "lang.conf"});
var en = {};
var zhcn = {};
var zhtw = {};
_.forEach(d, function(item){
    var temp = JSON.parse(_hocon.parseFile(item.path));
    var fuck = /.*\/(.*)\/lang\.conf$/.exec(item.path)[1];
    en[fuck] = _.mapValues(temp, 'en');
    zhcn[fuck] = _.mapValues(temp, 'zhcn');
    zhtw[fuck] = _.mapValues(temp, 'zhtw');
});

_fs.writeFile("D:/en.json", JSON.stringify(en, null, ' '));
_fs.writeFile("D:/zhcn.json", JSON.stringify(zhcn, null, ' '));
_fs.writeFile("D:/zhtw.json", JSON.stringify(zhtw, null, ' '));