Skip to content
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

Support range versions of NUMBER and DATETIME as default builtins #597

Open
angryzor opened this issue Sep 6, 2022 · 4 comments
Open

Support range versions of NUMBER and DATETIME as default builtins #597

angryzor opened this issue Sep 6, 2022 · 4 comments

Comments

@angryzor
Copy link

angryzor commented Sep 6, 2022

The JavaScript Intl API supports formatRange on both Intl.DateTimeFormat and Intl.NumberFormat. As far as I know these methods are not represented in the builtin functions in fluent.js. Would it be possible to add support for these?

I'm willing to try to make a pull request but I'd like to know the maintainers' stance on this first.

@eemeli
Copy link
Member

eemeli commented Sep 6, 2022

It would probably make more sense for date and time ranges to be represented by their own FluentType implementations rather than extending FluentNumber and FluentDateTime. Correspondingly, the functions for generating them should probably be separate from NUMBER() and DATETIME(), even though they may internally use the same Intl formatters.

It should be possible for you to build and use all of that via the functions option of the FluentBundle constructor, rather than needing to extend the default builtins. If you do so and make the functions available as an npm package, we'd be happy to link to it from here.

@angryzor
Copy link
Author

angryzor commented Sep 6, 2022

Makes sense. This is more or less what I had done now in my application, so I'll try to wrap it up in a package.

@angryzor
Copy link
Author

angryzor commented Nov 3, 2022

Hello @eemeli . I finally got around to bundling my solution up properly, so here is the link: https://github.com/angryzor/fluent-ranges

@eemeli
Copy link
Member

eemeli commented Nov 8, 2022

@angryzor That looks pretty great! We should take a closer look at this once number range formatting is a bit more widely supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants