SkirdaElectronLauncher/app/assets/js/langloader.js

21 lines
445 B
JavaScript
Raw Permalink Normal View History

2019-04-08 03:33:40 +00:00
const fs = require('fs-extra')
const path = require('path')
let lang
exports.loadLanguage = function(id){
lang = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'lang', `${id}.json`))) || {}
2019-04-08 03:33:40 +00:00
}
exports.query = function(id){
let query = id.split('.')
let res = lang
for(let q of query){
res = res[q]
}
return res === lang ? {} : res
}
exports.queryJS = function(id){
return exports.query(`js.${id}`)
}