From beb9f6cafe7c076b4d3a15b9bfd188f16868f1d8 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Thu, 22 Sep 2022 05:22:31 -0500 Subject: [PATCH] Add grouped locale string util for locale ID --- scripts/server/locale.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/server/locale.js b/scripts/server/locale.js index 466bea11..53435db2 100644 --- a/scripts/server/locale.js +++ b/scripts/server/locale.js @@ -23,6 +23,10 @@ class LocaleData { // =========================================================================== +let englishLocale = 0; + +// =========================================================================== + function initLocaleScript() { logToConsole(LOG_DEBUG, "[AGRP.Locale]: Initializing locale script ..."); logToConsole(LOG_INFO, "[AGRP.Locale]: Locale script initialized!"); @@ -68,6 +72,23 @@ function getLanguageLocaleString(localeId, stringName, ...args) { // =========================================================================== +function getLanguageGroupedLocaleString(localeId, stringName, index, ...args) { + let tempString = getRawGroupedLocaleString(stringName, index, localeId); + if (tempString == "" || tempString == null || typeof tempString == "undefined") { + logToConsole(LOG_WARN, `[AGRP.Locale] Locale string missing for index ${index} of "${stringName}" on language ${getLocaleData(localeId).englishName}`); + submitBugReport(null, `(AUTOMATED REPORT) Locale string index ${index} of "${stringName}" is missing for "${getLocaleData(localeId).englishName}"`); + return ""; + } + + for (let i = 1; i <= args.length; i++) { + tempString = tempString.replace(`{${i}}`, args[i - 1]); + } + + return tempString; +} + +// =========================================================================== + function getGroupedLocaleString(client, stringName, index, ...args) { if (client == null) { return "";