Skip to content

Commit

Permalink
Merge branch 'develop' into pr-preview-4
Browse files Browse the repository at this point in the history
git merge
  • Loading branch information
alex-solo committed Jun 10, 2024
2 parents f62be35 + 04bb4c5 commit 174a18b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion i18n/api/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ const fr: Translations = {
futureEligible60:
'Vous serez probablement admissible lorsque vous aurez 60 ans.',
futureEligible:
'Vous serez probablement admissible lorsque vous aurez {EARLIEST_ELIGIBLE_AGE} ans.',
'Vous serez probablement admissible lorsque vous aurez {EARLIEST_ELIGIBLE_AGE}.',
eligibleIncomeTooHigh:
'Vous êtes probablement admissible à cette prestation, mais votre revenu est trop élevé pour recevoir un paiement mensuel pour le moment.',
futureEligibleIncomeTooHigh:
Expand Down
8 changes: 5 additions & 3 deletions utils/api/definitions/textReplacementRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const textReplacementRules: TextReplacementRules = {
? handler.fields.translations.incomeCombined
: handler.fields.translations.incomeSingle,
EARLIEST_ELIGIBLE_AGE: (handler) =>
getEligibleAgeWithMonths(handler.rawInput.age),
getEligibleAgeWithMonths(handler.rawInput.age, handler.rawInput._language),
LINK_SERVICE_CANADA: (handler) =>
generateLink(handler.fields.translations.links.SC),
MY_SERVICE_CANADA: (handler) =>
Expand Down Expand Up @@ -135,15 +135,17 @@ export function generateLink(link: Link, opensNewWindow?: string): string {
return `<a class="underline text-default-text generatedLink" href="${link.url}" target="_blank">${link.text}</a>`
}

export function getEligibleAgeWithMonths(age: number) {
export function getEligibleAgeWithMonths(age: number, language: string) {
if (Number.isInteger(age)) {
return age.toString()
}

const years = Math.floor(age)
const months = Math.round((age - years) * 12)

return `${years} years and ${months} months`
return language === 'en'
? `${years}&nbsp;years and ${months}&nbsp;months`
: `${years}&nbsp;ans et ${months}&nbsp;mois`
}

export function getMaxYear(): number {
Expand Down

0 comments on commit 174a18b

Please sign in to comment.