21 lines
448 B
JavaScript
21 lines
448 B
JavaScript
const fs = require('fs-extra')
|
|
const path = require('path')
|
|
|
|
let lang
|
|
|
|
exports.loadLanguage = function(id){
|
|
lang = JSON.parse(fs.readFileSync(path.resolve('app', 'assets', 'lang', `${id}.json`))) || {}
|
|
}
|
|
|
|
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}`)
|
|
} |