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

[11.x] Add precision to Number::currency() #54456

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from

Conversation

benjibee
Copy link

@benjibee benjibee commented Feb 3, 2025

This pull request adds support for specifying precision when formatting currency with the Number helper.

The most common use-case for this is showing larger prices (e.g. $299 or $1000) where the numbers after the decimal place aren't desired in certain contexts. Because different locales use different symbols for decimal places this can't be done properly after the fact.

@shaedrich
Copy link
Contributor

#54360 and #54163 may be interesting to you

@benjibee
Copy link
Author

benjibee commented Feb 3, 2025

#54360 and #54163 may be interesting to you

I hadn't seen these, thanks for pointing them out. The use-case and implementation here is a bit more limited in scope as I'm not trying to adjust the way anything is calculated or how the data is passed into the helper.

If there was a good workaround I would use it. But because of the way locales and NumberFormatter work, this really needs to be a parameter passed to the helper to work properly.

@shaedrich
Copy link
Contributor

I hadn't seen these, thanks for pointing them out.

You're welcome.

But because of the way locales and NumberFormatter work, this really needs to be a parameter passed to the helper to work properly.

However, precision is usually associated with number formatting, not so much with money. That's why we discussed a currency-based approach in #54163 as they can be three decimal places for some currencies and two for others, which you would overwrite with a static precision.

@crynobone crynobone changed the title Add precision to Number::currency() [11.x] Add precision to Number::currency() Feb 4, 2025
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

Successfully merging this pull request may close these issues.

2 participants