Add configurable fallback locale as settings.fallbackLocale

This commit is contained in:
7cc5c4f330d47060 2024-09-21 15:09:40 -04:00
parent a71121225c
commit 9e03210af4
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA

View file

@ -1,5 +1,7 @@
const fs = require('fs')
const languages = {}
const settings = require('../settings.json')
const fallbackLocale = settings.fallbackLocale ? settings.fallbackLocale : "en-US";
const loadplug = (botno) => {
const bpl = fs.readdirSync('lang')
@ -18,8 +20,8 @@ const getMessage = function (l, msg, with2) {
let message = msg.replace(/%%/g, '\ue123')
if (languages[l] && languages[l][message] !== undefined) {
message = languages[l][message].replace(/%%/g, '\ue123')
} else if (languages['en-US'] && languages['en-US'][message] !== undefined) {
message = languages['en-US'][message].replace(/%%/g, '\ue123')
} else if (languages[fallbackLocale] && languages['en-US'][message] !== undefined) {
message = languages[fallbackLocale][message].replace(/%%/g, '\ue123')
}
if (with2) {
with2.forEach((withItem, i) => {