Skip to content

Commit e2c0f1d

Browse files
committed
MOBILE-3890 lang: Check language exists on settings
1 parent a4428b7 commit e2c0f1d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/classes/lang-loader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class MoodleTranslateLoader implements TranslateLoader {
6363
* @returns Promise resolved with the translations object or empty object if not found.
6464
*/
6565
protected async loadLanguage(lang: string): Promise<TranslationObject> {
66-
// Return the imported translations for the requested language
66+
// Return the imported translations for the requested language.
6767
let translation = await this.fetchLanguageFile(lang);
6868

6969
this.translations[lang] = translation;
@@ -103,7 +103,7 @@ export class MoodleTranslateLoader implements TranslateLoader {
103103
} catch (error) {
104104
this.logger.error('Error fetching language file', lang, error);
105105

106-
return {};
106+
throw error;
107107
}
108108
}
109109

@@ -115,7 +115,7 @@ export class MoodleTranslateLoader implements TranslateLoader {
115115
* @returns Parent language code or undefined if not found.
116116
*/
117117
getParentLanguage(lang: string): string | undefined {
118-
const parentLang = this.translations[lang][MoodleTranslateLoader.PARENT_LANG_KEY] as string | undefined;
118+
const parentLang = this.translations[lang]?.[MoodleTranslateLoader.PARENT_LANG_KEY] as string | undefined;
119119
if (parentLang && parentLang !== MoodleTranslateLoader.PARENT_LANG_KEY && parentLang !== lang) {
120120
return parentLang;
121121
}

0 commit comments

Comments
 (0)