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

format_currency with standard:short format does not format correctly #923

Closed
DenverCoder1 opened this issue Nov 2, 2022 · 0 comments · Fixed by #926
Closed

format_currency with standard:short format does not format correctly #923

DenverCoder1 opened this issue Nov 2, 2022 · 0 comments · Fixed by #926

Comments

@DenverCoder1
Copy link
Contributor

DenverCoder1 commented Nov 2, 2022

Overview Description

Currently there isn't a way to properly format currencies in compact form by locale.

The data is partially imported to locale.currency_formats["standard:short"]

>>> list(Locale("en_US").currency_formats)
['standard', 'accounting', 'standard:short']

But it does not store it for all magnitudes, rather just the last one

>>> Locale("en_US").currency_formats["standard:short"]
<NumberPattern '¤000T'>

This leads to standard:short format not formatting numbers correctly

>>> numbers.format_currency(1.98, 'USD', format_type="standard:short")
'$001.98T'

Additional Information

The import_cldr.py needs to be updated to correctly store the patterns for all magnitudes and count types ("one", "other")

It may also make sense to make a new function, for example, format_compact_currency to make the API similar to newly added format_compact_decimal.

@DenverCoder1 DenverCoder1 changed the title format_currency with standard:short format does not format correctly format_currency with standard:short format does not format correctly Nov 2, 2022
@akx akx closed this as completed in #926 Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants