-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) Age should be represented in internationalized translated way #765
Conversation
Size Change: -674 kB (-19%) 👏 Total Size: 2.79 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't accept this as-is, I think. It's common to refer to ages under 2 years (and sometimes three) by months, that is "18 months" rather than "1 year 6 months", even though these refer to the same period of time. If we want to make that English-specific, I'd accept it with the endorsement of a non-English-speaking pediatrician, but absent that, we should maintain the same output as is already here.
Also, it would be best if we didn't do all of the calculations of every possible string every time, but only when they were relevant.
@@ -67,24 +67,64 @@ export function age(dateString: string): string { | |||
// The "remainder" number of days after the weeksAgo number of weeks | |||
const remainderDaysInWeek = totalDaysAgo - weeksAgo * 7; | |||
|
|||
const rtf = new Intl.RelativeTimeFormat(getLocale(), { numeric: "auto" }); | |||
|
|||
const totalDaysAgoStr = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, a couple more small things:
- Can we reduce the
getLocale()
calls to a single call? - It would be nice if we only calculated the strings we're actually using instead of all of them every time.
- For weeks ago, I'd probably leave of the "days". Although this is relevant, I'm worried that the word order isn't always going to render properly, e.g., for Hebrew and Arabic, and we can fix that later.
Hi @ibacher ! |
Requirements
For changes to apps
If applicable
Summary
The age function currently returns the age in english strings, i.e. "4 years", "4 weeks". The age function will now return the age according to the locale of the application.
Screenshots
Infant born on the same day
Infant smaller than 1 month
Infant less than 1 year
Child less than 2 years
Age in years
Related Issue
Other