-
Notifications
You must be signed in to change notification settings - Fork 108
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 compactDisplay: 'long'
in currency formatting
#892
Comments
Also see tc39/proposal-unified-intl-numberformat#95 As you found, the CLDR ticket was closed due to a lack of clear use cases. If you can give some illustrative examples, it would be sufficient to reopen the ticket. |
Thank you for the additional details! It doesn't exactly give you the requested output, but I'll point out that the following works: new Intl.NumberFormat("en", {
style: "currency",
currency: "USD",
notation: "compact",
compactDisplay: "long",
currencyDisplay: "name"
}).format(1000000)
// '1 million US dollars' |
Also, just to note,
The TG does not usually see arguments of the form "A is motivated and B is motivated so why aren't A and B supported at the same time" to be a compelling argument. If it were, the surface of ECMA-402 would explode with a lot more data and APIs that need to be shipped and maintained despite not being useful to developers. We therefore require proposals to demonstrate that they are independently useful to the web platform. |
Fair enough on the latter point -- I totally understand that putting effort into an implementation requires a reason to do so, but I struggled a bit describing the use case other than "our clients/designers specify it fairly regularly", heh. And thanks for the syntax tip -- it still presents the challenge of replacing the currency word in various languages, but it's good to know it's another potential way to work around it. Thank you! |
It would be useful and consistent for
currency
formatting to follow the same pattern for compact notation as other numbers.Example:
If a currency value is to be presented with this formatting, it currently requires clumsy and error-prone string replacement that does not lend itself to consistent, correct internationalization of the content.
I discovered a relevant CLDR ticket, but it was closed without being pursued. I don't know whether it would be possible to revisit this discussion or to open another ticket to request this. Use cases for this formatting have come up numerous times in my work, and there is seemingly no solution that does not involve hard-coded exceptions to replace characters in the string for each localization. If it is accepted that there are use cases for "1 million", why would there not be use cases for "$1 million"?
The text was updated successfully, but these errors were encountered: