From 5ee4d3ae3203b8b9ef1b00b0e84fdad5ff5256ca Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Mon, 20 May 2019 16:34:42 +0200
Subject: [PATCH] =?UTF-8?q?R=C3=A9par=C3=A9:=20traduction=20des=20ouvrages?=
 =?UTF-8?q?=20en=20parall=C3=A8le?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/app/services/formulaire/formulaire.service.ts | 15 +++++++++++++--
 .../internationalisation.service.ts               |  8 --------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts
index a93424c56..642f163ad 100644
--- a/src/app/services/formulaire/formulaire.service.ts
+++ b/src/app/services/formulaire/formulaire.service.ts
@@ -161,7 +161,8 @@ export class FormulaireService extends Observable {
      */
     public expandVariableName(calcType: CalculatorType, symbol: string): string {
         let s = "";
-        let langCache = this.languageCache; // language cache…
+        // language cache…
+        let langCache = this.languageCache;
         if (langCache && langCache[calcType]) {
             langCache = langCache[calcType]; // …for target Nub type
         }
@@ -171,7 +172,17 @@ export class FormulaireService extends Observable {
         if (langCache && langCache[symbol] !== undefined) {
             s = this.intlService.localizeText(symbol, langCache);
         } else {
-            s = this.intlService.localizeText("INFO_LIB_" + symbol.toLocaleUpperCase());
+            // is symbol of the form ouvrages[i]… ?
+            const re = /([A-Z,a-z]+)\[(\d+)\]\.(.+)/;
+            const match = re.exec(symbol);
+            if (match) {
+                // Les libellés correspondants sont INFO OUVRAGE et INFO_EXTRARES_LIB_OUVRAGE_XXX
+                s = this.intlService.localizeText(`INFO_${match[1].toUpperCase()}`)
+                + " n°" + (+match[2] + 1) + ": "
+                + this.expandVariableName(calcType, `${match[1].toUpperCase()}_${match[3].toUpperCase()}`);
+            } else {
+                s = this.intlService.localizeText("INFO_LIB_" + symbol.toLocaleUpperCase());
+            }
         }
         return s;
     }
diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts
index 73e54b551..bd560fae2 100644
--- a/src/app/services/internationalisation/internationalisation.service.ts
+++ b/src/app/services/internationalisation/internationalisation.service.ts
@@ -177,14 +177,6 @@ export class I18nService extends Observable implements Observer {
         return str.replace(new RegExp(find, "g"), replace);
     }
 
-    /**
-     * analyse un libellé du type ouvrage[n].XX
-     */
-    private parseLabel(lbl: string) {
-        const re = /([A-Z,a-z]+)\[(\d+)\]\.(.+)/;
-        return re.exec(lbl);
-    }
-
     /**
      * Met en forme un extraResult en fonction du libellé qui l'accompagne
      * Les extraResult avec le terme "ENUM_" sont traduit avec le message INFO_EXTRARES_ENUM_[Nom de la variable après ENUM_]
-- 
GitLab