From c33999419830f83f1a375946ca198d3881888741 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 9 Jun 2022 13:51:43 +0200
Subject: [PATCH] fix: I18nService.setLanguage(): exclude some calculator types
 to prevent error messages in browser console at application startup

refs #499
---
 src/app/services/internationalisation.service.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/app/services/internationalisation.service.ts b/src/app/services/internationalisation.service.ts
index 1d9438227..4b8f545f6 100644
--- a/src/app/services/internationalisation.service.ts
+++ b/src/app/services/internationalisation.service.ts
@@ -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
             });
         }
     }
-- 
GitLab