feat: add localization to admin nav + locale sections

This commit is contained in:
NGPixel
2018-06-17 17:29:19 -04:00
parent 4b0428212d
commit 99d7078c2c
12 changed files with 136 additions and 63 deletions

View File

@@ -30,8 +30,8 @@ module.exports = {
})
}
// Load current language
this.loadLocale(WIKI.config.lang.code, { silent: true })
// Load current language + namespaces
this.refreshNamespaces(true)
return this
},
@@ -64,8 +64,16 @@ module.exports = {
throw new Error('No such locale in local store.')
}
},
async refreshNamespaces (silent = false) {
await this.loadLocale(WIKI.config.lang.code, { silent })
if (WIKI.config.lang.namespacing) {
for (let ns of WIKI.config.lang.namespaces) {
await this.loadLocale(ns, { silent })
}
}
},
async setCurrentLocale(locale) {
return Promise.fromCallback(cb => {
await Promise.fromCallback(cb => {
return this.engine.changeLanguage(locale, cb)
})
}