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

Currency DBField doesn't allow setting different thousands & decimals separators #8216

micschk opened this issue Jun 25, 2018 · 1 comment


Copy link

@micschk micschk commented Jun 25, 2018

Affected Version

3., 4.


In some locales, currencies use different separators, eg in Dutch (Netherlands) we use '€1.000,00' (as opposed to '$1,000.00'). The Currency field internally uses number_format(), this allows setting both characters. Allowing config values for both on Currency class and feeding them as 3rd & 4th agument fixes this (PR on its way).

micschk added a commit to micschk/sapphire that referenced this issue Jun 25, 2018

This comment has been minimized.

Copy link

@robbieaverill robbieaverill commented Oct 4, 2018

We use the intl PHP library already for date and time formatting, so we should change it to use NumberFormatter to handle all of this.

Quick investigation:

  • We have a configurable currency symbol. This becomes irrelevant with NumberFormatter, because it adds its own symbol for the current locale, and also allows you to format as another currency and have that symbol be used instead. We should deprecate the currency_symbol prop, but we'd also have to add some hacks to ensure it's still honoured if used until 5.x
  • We format negative numbers as ($5.20) rather than -$5.20. The latter is what NumberFormatter would return, so we'll need to also handle that in custom code.
  • We can use NumberFormatter::CURRENCY for the standard "Nice" formatting
  • We'd need to customise the format slightly to achieve the "Whole" formatting (removing the decimals and rounding up). This SO post looks like what we'd need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.