Skip to content
Snippets Groups Projects
Commit 3556b203 authored by David Dorchies's avatar David Dorchies
Browse files

#43 Ajout des libellés des extraResults + Simplification de la gestion des...

#43 Ajout des libellés des extraResults + Simplification de la gestion des libellés des extraresults et des ENUM dans les extraresults
parent 1f31c9c0
No related branches found
No related tags found
1 merge request!21Resolve "Ajout de la calculette "Dever""
...@@ -180,87 +180,37 @@ export class InternationalisationService extends Observable { ...@@ -180,87 +180,37 @@ export class InternationalisationService extends Observable {
} }
/** /**
* traduit un libellé qui peut être un code * Traduit un libellé qui peut être un code
*/ */
public translateLabel(o: any) { public translateLabel(s: string) {
let res; const key = "INFO_EXTRARES_LIB_";
if (typeof o === "string") { const match = this.parseLabel(s);
switch (o) { if (match) {
case "flu": // Code du type "Ouvrage[n].XXX"
res = this.localizeText("INFO_REMOUSRESULTS_LIGNEFLUVIALE"); // Les libellés correspondants sont INFO OUVRAGE et INFO_EXTRARES_LIB_OUVRAGE_XXX
break; return this.localizeText(`INFO_${match[1].toUpperCase()}`) + "" + (+match[2] + 1) + ": " +
this.localizeText(`${key}${match[1].toUpperCase()}_${match[3].toUpperCase()}`);
case "tor": } else {
res = this.localizeText("INFO_REMOUSRESULTS_LIGNETORRENTIELLE"); // Autres codes INFO_EXTRARES_LIB_XXX
break; return this.localizeText(`${key}${s.toUpperCase()}`);
default:
const match = this.parseLabel(o);
if (match) {
if (match[1] === "ouvrage")
res = this.localizeText("INFO_OUVRAGE") + "" + (+match[2] + 1);
const p = match[3];
switch (p) {
case "Q":
res += " : " + this.localizeText("INFO_GRANDEUR_" + p);
break;
case "Q_Mode":
res += " : " + this.localizeText("INFO_TYPE_ECOULEMENT");
break;
case "Q_Regime":
res += " : " + this.localizeText("INFO_REGIME");
break;
}
}
else
res = o;
break;
}
} }
return res; }
}
/** /**
* met en forme ou traduit un résultat en fonction du libellé qui l'accompagne * met en forme ou traduit un résultat en fonction du libellé qui l'accompagne
* @todo Il manque un formalisme clair permettant de différencier les valeurs numériques des ENUM
*/ */
public formatResult(label: string, value: number): string { public formatResult(label: string, value: number): string {
const match = this.parseLabel(label); const match = this.parseLabel(label);
if (match) if (match) {
switch (match[1]) { if (match[3] !== "Q") { // Le débit est une valeur numérique, tous les autres sont des ENUM ???
case "ouvrage": // Label du type ouvrage[n].XXX => message INFO_EXTRARES_ENUM_OUVRAGE_XXX_value
switch (match[3]) { return this.localizeText(`INFO_EXTRARES_ENUM_${match[1].toUpperCase()}_${match[3].toUpperCase()}_${value}`);
case "Q_Mode":
switch (value) {
case 0:
case 1:
case 2:
const key = `INFO_LIB_ENUM_RES_STRUCTURE_MODE_${value}`;
return this.localizeText(key);
default:
throw new Error(`InternationalisationService.formatResult : valeur ${value} incorrecte pour STRUCTURE_MODE`);
}
case "Q_Regime":
switch (value) {
case 0:
case 1:
case 2:
const key = `INFO_LIB_ENUM_RES_STRUCTURE_REGIME_${value}`;
return this.localizeText(key);
default:
throw new Error(`InternationalisationService.formatResult : valeur ${value} incorrecte pour STRUCTURE_REGIME`);
}
}
} }
}
const appSetupService = ServiceFactory.instance.applicationSetupService; const appSetupService = ServiceFactory.instance.applicationSetupService;
const nDigits = appSetupService.displayDigits; const nDigits = appSetupService.displayDigits;
return value.toFixed(nDigits); return value.toFixed(nDigits);
} }
} }
...@@ -69,8 +69,6 @@ ...@@ -69,8 +69,6 @@
"INFO_GRANDEUR_TAU0": "La force tractrice (Pa)", "INFO_GRANDEUR_TAU0": "La force tractrice (Pa)",
"INFO_COURBEREMOUS_TITRE": "Courbes de remous", "INFO_COURBEREMOUS_TITRE": "Courbes de remous",
"INFO_REMOUSRESULTS_TITREJOURNAL": "Journal de calcul", "INFO_REMOUSRESULTS_TITREJOURNAL": "Journal de calcul",
"INFO_REMOUSRESULTS_LIGNEFLUVIALE": "Ligne d'eau fluviale",
"INFO_REMOUSRESULTS_LIGNETORRENTIELLE": "Ligne d'eau torrentielle",
"INFO_REMOUSRESULTS_ABSCISSE": "Abscisse (m)", "INFO_REMOUSRESULTS_ABSCISSE": "Abscisse (m)",
"INFO_REMOUSRESULTS_TIRANT": "Tirant d'eau (m)", "INFO_REMOUSRESULTS_TIRANT": "Tirant d'eau (m)",
"INFO_REMOUSRESULTS_FOND": "Fond", "INFO_REMOUSRESULTS_FOND": "Fond",
...@@ -91,15 +89,26 @@ ...@@ -91,15 +89,26 @@
"INFO_PARALLELSTRUCTURE_TITRE": "Ouvrages en parallèle", "INFO_PARALLELSTRUCTURE_TITRE": "Ouvrages en parallèle",
"INFO_DEVER_TITRE": "Outil dever", "INFO_DEVER_TITRE": "Outil dever",
"INFO_OUVRAGE": "Ouvrage", "INFO_OUVRAGE": "Ouvrage",
"INFO_TYPE_ECOULEMENT": "Type d'écoulement",
"INFO_REGIME": "Régime", "INFO_EXTRARES_LIB_FLU": "Ligne d'eau fluviale",
"INFO_EXTRARES_LIB_TOR": "Ligne d'eau torrentielle",
"INFO_EXTRARES_LIB_OUVRAGE_Q": "Débit (m³/s)",
"INFO_EXTRARES_LIB_OUVRAGE_Q_MODE": "Type d'écoulement",
"INFO_EXTRARES_LIB_OUVRAGE_Q_REGIME": "Régime",
"INFO_EXTRARES_LIB_V": "V: Vitesse (m/s)",
"INFO_EXTRARES_LIB_EC": "EC: Énergie cinétique (m)",
"INFO_EXTRARES_LIB_CV": "Cv: Coefficient de vitesse d'approche",
"INFO_EXTRARES_LIB_CVQT": "CV.QT: Débit corrigé (m³/s)",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_MODE_0": "Surface libre",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_MODE_1": "En charge",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_MODE_2": "Débit nul",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_0": "Dénoyé",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_1": "Partiellement noyé",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_2": "Noyé",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_3": "Débit nul",
"WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE": "La pelle du seuil doit mesurer au moins 0,1 m. Le coefficient béta est forcé à 0", "WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE": "La pelle du seuil doit mesurer au moins 0,1 m. Le coefficient béta est forcé à 0",
"WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p ne doit pas être supérieur à 2,5. h/p est forcé à 2,5", "WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p ne doit pas être supérieur à 2,5. h/p est forcé à 2,5"
"INFO_LIB_ENUM_RES_STRUCTURE_MODE_0": "Surface libre",
"INFO_LIB_ENUM_RES_STRUCTURE_MODE_1": "En charge",
"INFO_LIB_ENUM_RES_STRUCTURE_MODE_2": "Débit nul",
"INFO_LIB_ENUM_RES_STRUCTURE_REGIME_0": "Dénoyé",
"INFO_LIB_ENUM_RES_STRUCTURE_REGIME_1": "Partiellement noyé",
"INFO_LIB_ENUM_RES_STRUCTURE_REGIME_2": "Noyé",
"INFO_LIB_ENUM_RES_STRUCTURE_REGIME_3": "Débit nul"
} }
\ No newline at end of file
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