Skip to content

Commit

Permalink
Change type for translations in element-desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Hanff committed Mar 9, 2024
1 parent cfa26d2 commit 82a2037
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/language-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -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);
Expand Down

0 comments on commit 82a2037

Please sign in to comment.