Change type for translations in element-desktop

This commit is contained in:
Nils Hanff 2024-03-09 12:38:06 +01:00
parent cfa26d22a3
commit 82a20371dc
No known key found for this signature in database
GPG key ID: 0BD540C68B2BEAEE

View file

@ -113,7 +113,7 @@ export class AppLocalization {
return parts.join("_");
}
public fetchTranslationJson(locale: string): Record<string, string> | null {
public fetchTranslationJson(locale: string): object | null {
try {
console.log(`Fetching translation json for locale: ${locale}`);
return loadJsonFile(__dirname, "i18n", "strings", `${locale}.json`);
@ -130,13 +130,16 @@ export class AppLocalization {
locales = [locales];
}
const loadedLocales = locales.flatMap(this.variations).map(this.denormalize).filter((locale) => {
const translations = this.fetchTranslationJson(locale);
if (translations !== null) {
counterpart.registerTranslations(locale, translations);
}
return !!translations;
});
const loadedLocales = locales
.flatMap(this.variations)
.map(this.denormalize)
.filter((locale) => {
const translations = this.fetchTranslationJson(locale);
if (translations !== null) {
counterpart.registerTranslations(locale, translations);
}
return !!translations;
});
counterpart.setLocale(loadedLocales[0]);
this.store.set(AppLocalization.STORE_KEY, locales);