From 591823f90e693ebb473dffa7769057ce79313e38 Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Thu, 14 Dec 2023 01:28:09 -0500 Subject: [PATCH] Adjust locale fallback This fixes #1701 --- renderer/src/modules/localemanager.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/renderer/src/modules/localemanager.js b/renderer/src/modules/localemanager.js index dcbd7a80..09f10c44 100644 --- a/renderer/src/modules/localemanager.js +++ b/renderer/src/modules/localemanager.js @@ -11,7 +11,6 @@ export default new class LocaleManager { get defaultLocale() {return "en-US";} constructor() { - this.locale = ""; this.strings = Utilities.extend({}, Locales[this.defaultLocale]); } @@ -21,16 +20,13 @@ export default new class LocaleManager { } setLocale() { - let newStrings; - if (this.discordLocale != this.defaultLocale) { - newStrings = Locales[this.discordLocale]; - if (!newStrings) return this.setLocale(this.defaultLocale); - } - else { - newStrings = Locales[this.defaultLocale]; - } - this.locale = this.discordLocale; - Utilities.extendTruthy(this.strings, newStrings); + // Reset to the default locale in case a language is incomplete + Utilities.extend(this.strings, Locales[this.defaultLocale]); + + // Get the strings of the new language and extend if a translation exists + const newStrings = Locales[this.discordLocale]; + if (newStrings) Utilities.extendTruthy(this.strings, newStrings); + Events.emit("strings-updated"); } }; \ No newline at end of file