2022-07-14 12:25:24 -07:00
|
|
|
/**
|
|
|
|
* @author Daniel D. Scalzi
|
|
|
|
* @license CC-BY-NC 4.0 - https://creativecommons.org/licenses/by-nc/4.0/
|
|
|
|
*/
|
|
|
|
|
2019-04-07 20:33:40 -07:00
|
|
|
const fs = require('fs-extra')
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
let lang
|
|
|
|
|
|
|
|
exports.loadLanguage = function(id){
|
2019-04-23 13:53:32 -07:00
|
|
|
lang = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'lang', `${id}.json`))) || {}
|
2019-04-07 20:33:40 -07: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}`)
|
|
|
|
}
|