From 9e03210af451988c10dfe87eaf696147d0f62d48 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Sat, 21 Sep 2024 15:09:40 -0400 Subject: [PATCH] Add configurable fallback locale as settings.fallbackLocale --- util/lang.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/lang.js b/util/lang.js index 44ce2f3..eff73be 100755 --- a/util/lang.js +++ b/util/lang.js @@ -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) => {