Add configurable fallback locale as settings.fallbackLocale
This commit is contained in:
parent
a71121225c
commit
9e03210af4
1 changed files with 4 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const languages = {}
|
const languages = {}
|
||||||
|
const settings = require('../settings.json')
|
||||||
|
const fallbackLocale = settings.fallbackLocale ? settings.fallbackLocale : "en-US";
|
||||||
|
|
||||||
const loadplug = (botno) => {
|
const loadplug = (botno) => {
|
||||||
const bpl = fs.readdirSync('lang')
|
const bpl = fs.readdirSync('lang')
|
||||||
|
@ -18,8 +20,8 @@ const getMessage = function (l, msg, with2) {
|
||||||
let message = msg.replace(/%%/g, '\ue123')
|
let message = msg.replace(/%%/g, '\ue123')
|
||||||
if (languages[l] && languages[l][message] !== undefined) {
|
if (languages[l] && languages[l][message] !== undefined) {
|
||||||
message = languages[l][message].replace(/%%/g, '\ue123')
|
message = languages[l][message].replace(/%%/g, '\ue123')
|
||||||
} else if (languages['en-US'] && languages['en-US'][message] !== undefined) {
|
} else if (languages[fallbackLocale] && languages['en-US'][message] !== undefined) {
|
||||||
message = languages['en-US'][message].replace(/%%/g, '\ue123')
|
message = languages[fallbackLocale][message].replace(/%%/g, '\ue123')
|
||||||
}
|
}
|
||||||
if (with2) {
|
if (with2) {
|
||||||
with2.forEach((withItem, i) => {
|
with2.forEach((withItem, i) => {
|
||||||
|
|
Loading…
Reference in a new issue