-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
Allow formatting of number strings #1492
Comments
Interesting, could definitely be worth considering—thanks for the report! This will need some investigation first, e.g.:
|
Browser and runtime support seem decent (except Deno):
|
One implication of this in combination with #1499 would be that we can currently do this (ref): "{count} followers"
// ^? {count: string}
"{count, number} followers"
// ^? {count: number} That helps to make sure you're using the If we allow numbers as strings, we'd allow |
A note from https://x.com/SlexAxton/status/1859242191408746751 on support of string-based numbers in Format.JS:
Might be worth checking if this is something we could safely use. |
Is your feature request related to a problem? Please describe.
The number formatter in this package allows
number
orbigint
input only.When working with very larger numbers, we typically use other libraries that can deal with high precision. However, in order to use
next-intl
number formatter, we have to turn those numbers back into native number values, which would be lossy and produce incorrect values.Describe the solution you'd like
Intl.NumberFormat
already supports astring
param that it can then format losslessly in modern browsers. Seeing how we delegate to this library anyway, it would be good to broaden the type ofnumber()
function.This way we can pass large numbers as string to the formatter and get a correct representation out.
Describe alternatives you've considered
My workaround is to just get the locale and do my own
Intl.NumberFormat
formatter. But then I have to forego or re-implement all the nice locale-awareness and caching thatnext-intl
has already got.The text was updated successfully, but these errors were encountered: