Fix Translations showing as untranslated keys (#983)

## Description:
Fixes translations showing as untranslated keys

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

<DISCORD USERNAME>
Nikola123
This commit is contained in:
Duwibi
2025-06-01 01:53:52 +03:00
committed by Scott Anderson
parent 2b65f5ce17
commit e7f9a40eeb
+11 -3
View File
@@ -78,10 +78,18 @@ export class LangSelector extends LitElement {
});
}
private getClosestSupportedLang(lang: string): string {
if (!lang) return "en";
if (lang in this.languageMap) return lang;
const base = lang.split("-")[0];
if (base in this.languageMap) return base;
return "en";
}
private async initializeLanguage() {
const locale = new Intl.Locale(navigator.language);
const defaultLang = locale.language;
const userLang = localStorage.getItem("lang") || defaultLang;
const browserLocale = navigator.language;
const savedLang = localStorage.getItem("lang");
const userLang = this.getClosestSupportedLang(savedLang || browserLocale);
this.defaultTranslations = await this.loadLanguage("en");
this.translations = await this.loadLanguage(userLang);