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

Support for currencyDecimal #586

Open
spookylukey opened this issue Jun 5, 2018 · 1 comment
Open

Support for currencyDecimal #586

spookylukey opened this issue Jun 5, 2018 · 1 comment

Comments

@spookylukey
Copy link
Contributor

Some locales (in fact, currently just one, namely fr_CH) define a currencyDecimal field. This value should be used as the decimal separator, but only for currency values.

babel doesn't use it though:

>>> print(format_currency(12345.678, 'USD', locale='fr_CH'))
12 345,68 $US

The expected output is 12 345.68 $US. Compare with JS Intl.NumberFormat (tested in Firefox and Chrome), which correctly has a . for the decimal separator instead of the ,:

> Intl.NumberFormat("fr-CH", {currencyDisplay:"symbol", style:"currency", currency:"USD"}).format(12345.678)
"12 345.68 $US "

The fix would probably involve passing a decimal_separator keyword argument to NumberPattern.apply, and using this from all branches of format_currency. It looks like the data needed is already available on Locale:

>>> Locale('fr_CH')._data['number_symbols']['currencyDecimal']
'.'

This is the only Locale that has that currencyDecimal key in number_symbols.

@Firefox2005
Copy link

+1. I would consider that as a bug. The decimal symbol is correct for other locales but wrong for fr_CH. When using de_CH it returns the correct decimal symbol for Switzerland, which is "."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants