Skip to content

Commit

Permalink
Task advanced : the text for a negative number in "nth day of the mon…
Browse files Browse the repository at this point in the history
…th" is not right (#5482)

Signed-off-by: Giovanni Ferrari <giovanni.ferrari@soft.it>
  • Loading branch information
quinarygio committed Dec 14, 2023
1 parent 2b30514 commit bbf8c77
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 8 deletions.
Expand Up @@ -88,9 +88,15 @@ export class TaskCardTemplateView {
if (bymonthday.includes("1")) textForBymonthday += opfab.utils.getTranslation("buildInTemplate.taskCard.firstDayOfTheMonth") + ", ";
if (bymonthday.includes("-1")) textForBymonthday += opfab.utils.getTranslation("buildInTemplate.taskCard.lastDayOfTheMonth") + ", ";
if (bymonthday.length > 0) {
if ((bymonthday[0] !== "1") && (bymonthday[0] !== "-1")) {
textForBymonthday += "The " + bymonthday[0] + this.cardinalToOrdinal(bymonthday[0]) + " " + opfab.utils.getTranslation("buildInTemplate.taskCard.dayOfTheMonth") + " , ";
this.replaceZero(bymonthday);
if (bymonthday[0] !== "1" && bymonthday[0] !== "-1") {
if (bymonthday[0].startsWith('-')) {
textForBymonthday += bymonthday[0].substring(1) + " " + opfab.utils.getTranslation("buildInTemplate.taskCard.daysBeforeEndOfTheMonth") + " , ";
} else {
textForBymonthday += opfab.utils.getTranslation("buildInTemplate.taskCard.the") + " " + bymonthday[0] + this.cardinalToOrdinal(bymonthday[0]) + " " + opfab.utils.getTranslation("buildInTemplate.taskCard.dayOfTheMonth") + " , ";
}
}

}
if (textForBymonthday !== "") {
textForBymonthday = textForBymonthday.slice(0, -2);
Expand Down Expand Up @@ -125,12 +131,11 @@ export class TaskCardTemplateView {
return null;
}

let ord = 'th';
if (card % 10 == 1 && card % 100 != 11){ ord = 'st'; }
else if (card % 10 == 2 && card % 100 != 12){ ord = 'nd'; }
else if (card % 10 == 3 && card % 100 != 13){ ord = 'rd'; }
return ord;
return opfab.utils.getTranslation("shared.ordinal.suffix." + card);
}


replaceZero(days: any[]) {
const zeroIndex = days.findIndex(d => d === "0");
if (zeroIndex >= 0) days[zeroIndex] = "1";
}
}
36 changes: 36 additions & 0 deletions ui/main/src/assets/i18n/en.json
Expand Up @@ -100,6 +100,41 @@
"october":"October",
"november":"November",
"december":"December"
},
"ordinal": {
"suffix": {
"1": "st",
"2": "nd",
"3": "rd",
"4": "th",
"5": "th",
"6": "th",
"7": "th",
"8": "th",
"9": "th",
"10": "th",
"11": "th",
"12": "th",
"13": "th",
"14": "th",
"15": "th",
"16": "th",
"17": "th",
"18": "th",
"19": "th",
"20": "th",
"21": "th",
"22": "th",
"23": "th",
"24": "th",
"25": "th",
"26": "th",
"27": "th",
"28": "th",
"29": "th",
"30": "th",
"31": "th"
}
}
},
"global":{
Expand Down Expand Up @@ -659,6 +694,7 @@
"on": "on",
"firstDayOfTheMonth": "The first day of the month",
"lastDayOfTheMonth": "The last day of the month",
"daysBeforeEndOfTheMonth": "days before the end of the month",
"dayOfTheMonth": "day of the month",
"in": "in"
},
Expand Down
36 changes: 36 additions & 0 deletions ui/main/src/assets/i18n/fr.json
Expand Up @@ -100,6 +100,41 @@
"october":"octobre",
"november":"novembre",
"december":"décembre"
},
"ordinal": {
"suffix": {
"1": "er",
"2": "nd",
"3": "e",
"4": "e",
"5": "e",
"6": "e",
"7": "e",
"8": "e",
"9": "e",
"10": "e",
"11": "e",
"12": "e",
"13": "e",
"14": "e",
"15": "e",
"16": "e",
"17": "e",
"18": "e",
"19": "e",
"20": "e",
"21": "e",
"22": "e",
"23": "e",
"24": "e",
"25": "e",
"26": "e",
"27": "e",
"28": "e",
"29": "e",
"30": "e",
"31": "e"
}
}
},
"global":{
Expand Down Expand Up @@ -661,6 +696,7 @@
"on": "le(s)",
"firstDayOfTheMonth": "Le premier jour du mois",
"lastDayOfTheMonth": "Le dernier jour du mois",
"daysBeforeEndOfTheMonth": "jours avant la fin du mois",
"dayOfTheMonth": "jour du mois",
"in": "en"
},
Expand Down
36 changes: 36 additions & 0 deletions ui/main/src/assets/i18n/nl.json
Expand Up @@ -100,6 +100,41 @@
"october":"Oktober",
"november":"November",
"december":"December"
},
"ordinal": {
"suffix": {
"1": "ste",
"2": "de",
"3": "de",
"4": "de",
"5": "de",
"6": "de",
"7": "de",
"8": "ste",
"9": "de",
"10": "de",
"11": "de",
"12": "de",
"13": "de",
"14": "de",
"15": "de",
"16": "de",
"17": "de",
"18": "de",
"19": "de",
"20": "ste",
"21": "ste",
"22": "ste",
"23": "ste",
"24": "ste",
"25": "ste",
"26": "ste",
"27": "ste",
"28": "ste",
"29": "ste",
"30": "ste",
"31": "ste"
}
}
},
"global":{
Expand Down Expand Up @@ -660,6 +695,7 @@
"on": "op",
"firstDayOfTheMonth": "De eerste dag van de maand",
"lastDayOfTheMonth": "De laatste dag van de maand",
"daysBeforeEndOfTheMonth": "dagen voor het einde van de maand",
"dayOfTheMonth": "dag van de maand",
"in": "in"
},
Expand Down

0 comments on commit bbf8c77

Please sign in to comment.