Skip to content
Snippets Groups Projects
Commit c3399941 authored by François Grand's avatar François Grand
Browse files

fix: I18nService.setLanguage(): exclude some calculator types to prevent error...

fix: I18nService.setLanguage(): exclude some calculator types to prevent error messages in browser console at application startup

refs #499
parent 5dfd1310
No related branches found
No related tags found
1 merge request!149Resolve "Error 404 on language files load"
Pipeline #139591 failed
......@@ -60,6 +60,11 @@ export class I18nService extends Observable implements Observer {
* @param code ISO 639-1 language code
*/
public async setLanguage(code: string) {
/** excluded calculators */
const childCalculatorType: CalculatorType[] = [
CalculatorType.Section, CalculatorType.Structure, CalculatorType.CloisonAval, CalculatorType.YAXN
];
// ensure 2-letter language code
code = code.substring(0, 2);
// is language supported ?
......@@ -75,7 +80,7 @@ export class I18nService extends Observable implements Observer {
const promisesList: Promise<any>[] = [];
for (const ct in CalculatorType) {
const calcType = Number(ct);
if (!isNaN(calcType)) {
if (!isNaN(calcType) && !childCalculatorType.includes(calcType)) {
promisesList.push(this.loadLocalisation(calcType).catch((err) => { /* silent fail */ }));
}
}
......@@ -118,7 +123,7 @@ export class I18nService extends Observable implements Observer {
}
} else {
return new Promise((resolve, reject) => {
resolve(); // does nothing but complies with Promise expectation
resolve(undefined); // does nothing but complies with Promise expectation
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment