-
Notifications
You must be signed in to change notification settings - Fork 187
Use Intl.RelativeTimeFormat #104
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
Conversation
|
@josh Nah I just started exploring and noticed that some tests for special cases that would break when we'd start using |
|
|
817c563 to
2f3e550
Compare
|
Alright, got tests passing here. Could use some review please 😁 |
koddsson
left a comment
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.
This looks good to me.
dgraham
left a comment
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.
😎
|
Would also love some feedback on the effect of this change for people who can speak more than English 😁 |
| try { | ||
| // eslint-disable-next-line flowtype/no-flow-fix-me-comments | ||
| // $FlowFixMe: missing RelativeTimeFormat type | ||
| format = new Intl.RelativeTimeFormat(undefined, options) |
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.
I think we want to pass en as the locale until we add a locale attribute to the custom element so it's configurable by the host app. That will prevent this text from appearing in the default locale for the browser with the rest of the text appearing in English.
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.
Yeah, I'm down to support that, though I was just stealing from our existing makeFormatter.
Will that need to change as well? Should I do this in a separate PR? Starting to wonder how this change is going to ship. It might be a major version bump. So could bundle this and that locale change in one release.
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.
I wonder if the runtime's default locale is hardcoded to en in browsers and this is different from the user's preferred language setting in the operating system. Anyway, since undefined is already working for DateTimeFormat, we can use it here too.
A major version release would be appropriate since this changes the text output slightly.
We could couple that with <relative-time locale="…"> if it's not too much work. The only weird thing is that the locale attribute would only apply to browsers with RelativeTimeFormat support. The older code path would still use the hardcoded English text.
2f3e550 to
5633266
Compare
Not sure what to do, or even if we have to deal with this. |
muan
left a comment
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.
Would also love some feedback on the effect of this change for people who can speak more than English 😁
Can confirmed that relative timestamps within the month all look pretty reasonable. 🙆 Not sure if there's anything specific I should look for.
|
Thanks! I'll move forward with merging this and open another PR attempt for the |
Aims to implement #98.
To-do
Intl.RelativeTimeFormat.localeattribute