reload language and definitions when a customAutoLoad module loads+

cron-as-worker-process
Moe 2022-06-07 17:40:53 -07:00
parent bf6738d722
commit 11c69d56ce
1 changed files with 13 additions and 8 deletions

View File

@ -3,18 +3,23 @@ module.exports = function(s,config){
if(!config.language){ if(!config.language){
config.language='en_CA' config.language='en_CA'
} }
try{ var lang = {};
var lang = {}; function getLanguageData(choice){
eval(`lang = ${fs.readFileSync(s.location.languages+'/'+config.language+'.json','utf8')}`) let gotLang = {}
}catch(er){ try{
console.error(er) eval(`gotLang = ${fs.readFileSync(s.location.languages+'/'+choice+'.json','utf8')}`)
console.log('There was an error loading your language file.') }catch(er){
eval(`lang = ${fs.readFileSync(s.location.languages+'/en_CA.json','utf8')}`) console.error(er)
console.log('There was an error loading your language file.')
eval(`gotLang = ${fs.readFileSync(s.location.languages+'/en_CA.json','utf8')}`)
}
return gotLang
} }
lang = getLanguageData(config.language)
//load languages dynamically //load languages dynamically
s.copySystemDefaultLanguage = function(){ s.copySystemDefaultLanguage = function(){
//en_CA //en_CA
return Object.assign({},lang) return Object.assign({},getLanguageData(config.language))
} }
s.listOfPossibleLanguages = [] s.listOfPossibleLanguages = []
fs.readdirSync(s.mainDirectory + '/languages').forEach(function(filename){ fs.readdirSync(s.mainDirectory + '/languages').forEach(function(filename){