diff options
Diffstat (limited to 'src/lang.js')
-rw-r--r-- | src/lang.js | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/lang.js b/src/lang.js index b3cc251..7397839 100644 --- a/src/lang.js +++ b/src/lang.js @@ -1,36 +1,12 @@ const fs = require("fs"); +const flat = require("flattenizer"); const json = require("./modules/json"); const enLang = json(__dirname + "/lang/en.json"); let lang = ""; var langObj = {}; -function flatten_obj(data) { - var obj = {}; - - for (let i in data) { - if (! data.hasOwnProperty(i)) { - continue; - } - - if (typeof data[i] == "object" && data[i] !== null) { - var flattened = flatten_obj(data[i]); - for (var ii in flattened) { - if (! flattened.hasOwnProperty(ii)) { - continue; - } - - obj[i + "." + ii] = flattened[ii]; - } - } else { - obj[i] = data[i]; - } - } - - return obj; -} - function _loadTranslation(forcedlang) { if (fs.existsSync("viper.json")) { // Validate viper.json @@ -65,7 +41,7 @@ function _loadTranslation(forcedlang) { lang = "en"; } - langObj = flatten_obj(json(__dirname + `/lang/${lang}.json`) || {}); + langObj = flat.flatten(json(__dirname + `/lang/${lang}.json`) || {}); } |