Open micschk opened 6 years ago
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:
currency_symbol
prop, but we'd also have to add some hacks to ensure it's still honoured if used until 5.x($5.20)
rather than -$5.20
. The latter is what NumberFormatter would return, so we'll need to also handle that in custom code.NumberFormatter::CURRENCY
for the standard "Nice" formattingAny news on this issue?
I suggest to add a methods like NiceI18N()
to all relevant classes for formatting the value with proper localisation. This can be deprecated for SS6 and become standard behaviour in SS6.
Relevant number formatting would be:
DBMoney already uses NumberFormatter
, but calling Money's Amount is a plain DBDecimal without any localisation support.
For having (3.00)
instead of -3.00
you can use https://www.php.net/manual/de/class.numberformatter.php#numberformatter.constants.currency-accounting
With a method for setting the formatter (e.g. currency vs currency-accounting) we could fine tune formatting in templates, like $MyValue.setFormatter('CURRENCY').Nice()
, though I suggest to set this in a config value globally.
Related Issues: #8216
Affected Version
3., 4.
Description
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).
Notes