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

Add support for number range formatting #540

Closed
vimtor opened this issue Oct 2, 2023 · 6 comments
Closed

Add support for number range formatting #540

vimtor opened this issue Oct 2, 2023 · 6 comments
Labels
contributions welcome Good for people looking to contribute enhancement New feature or request

Comments

@vimtor
Copy link

vimtor commented Oct 2, 2023

Is your feature request related to a problem? Please describe.

I want to format a range of numbers using the existing number range format API:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRange

Describe the solution you'd like

Either an option to the .number method in the Formatter object or a new numberRange method.

Describe alternatives you've considered

I've considered using the API directly, but it is only supported in Node.js 19. The latest version available in Vercel is Node.js 18.

@vimtor vimtor added enhancement New feature or request unconfirmed Needs triage. labels Oct 2, 2023
@amannn
Copy link
Owner

amannn commented Oct 2, 2023

Thanks for the feature request @vimtor! I think useFormatter().numberRange(startRange, endRange, options?) would be a great addition.

However, we rely on polyfills, so in regard to your question about Node.js 18 support, you'd have to polyfill the API anyway. Would that work for you?

@vimtor
Copy link
Author

vimtor commented Oct 3, 2023

Yes, @amannn! That would be a great addition :)

Regarding the polyfill, I assume the polyfill will be included with the library, right? If that is the case, it would work 100%

@amannn
Copy link
Owner

amannn commented Oct 3, 2023

next-intl doesn't do any polyfilling in order to reduce the library size (see the runtime requirements). In case we add support for number range formatting, we should add an entry for this API in the runtime requirements docs.

Would you be interested in contributing this feature? :)

@vimtor
Copy link
Author

vimtor commented Oct 21, 2023

Yes! I would love to contribute to this feature.

Would it be better to wait until the RSC integration is merged, right?

@amannn
Copy link
Owner

amannn commented Oct 23, 2023

Great to hear, I'm fine either way!

You can either:

  1. Make a PR against the main branch and we'll publish this in a minor version. Afterward, I'll rebase the RSC branch.
  2. Make a PR against the RSC branch and we'll release this as part of the 3.0 version.

I hope to stabilize the RSC integration in the next few weeks, so there shouldn't be much difference practically.

@amannn amannn added contributions welcome Good for people looking to contribute and removed unconfirmed Needs triage. labels Nov 23, 2023
@amannn
Copy link
Owner

amannn commented Jan 11, 2024

Superseded by #774. We can still add this if there's need for this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome Good for people looking to contribute enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants