-
Notifications
You must be signed in to change notification settings - Fork 744
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
Localise Interval output #325
Comments
I would love to do this but...it's complicated. So first, remember that Luxon doesn't have any idea how to do localization itself; it just uses what the browser has built in, and there's no API for localizing things like intervals. It still may be possible, though. I also maintain Twix, which is a Moment plugin that knows how to make nice strings like that (complicated, because it's "Sept 3-10", but "Sept 3 - Oct 10", etc), although not localized. I tried an experiment in Twix where I could take the localized date format and try to "zipper" it up based on that format instead of just based on hardcoded rules. It was unexpectedly complicated and I abandoned the effort. So when it came time to do it here, I decided against it for three reasons:
So I left it all out. I always thought I'd at least port the formatting parts of Twix to a Luxon plugin and maybe in the process finally finish the localization part, but I never did. So yes, out of scope. |
Makes sense. It's not a massive task to deal with this on a per case basis anyhow. Thanks for clarifying. |
Note that you can localize Interval output by leveraging Intl.DateTimeFormat.formatRange. Sadly, that API is only currently supported on Chrome, although you could fallback to |
I've yet to find a way to properly localise interval output. Given an interval with start date 09/03/2018 and end date 09/10/2018, would it be possible to support localised output like the below using toLocaleString on an Interval object?
'September 3 - 10' for 'en-US'
'3 - 10 September' for 'en-GB'
or is this out of the scope for this library?
Thanks
The text was updated successfully, but these errors were encountered: