-
Notifications
You must be signed in to change notification settings - Fork 464
Description
Namely, things like:
"123,456.78 US dollars"
(en locale)
or
"dólares estadounidenses 123,456.78"
(es-GT locale)
The algorithm for doing this is described here: https://www.unicode.org/reports/tr35/tr35-numbers.html#Currencies and CLDR contains the data.
I'd be happy to attempt to implement this myself. Two issues I'm aware of:
-
What should the API be? An extra parameter to
format_currency? A newformat_type(this risks clashing with other format types already defined)? -
It looks like this would require data not currently available in the pickled locale data. Specifically it requires the
unitPatterndata. I'm not sure how to go about adding this - apart from theimport_cldr.pyscript, is there a specific process to follow?
For comparison, browsers currently implement this as part of Intl.NumberFormat using options {currencyDisplay: "name"}. In a browser console you can do:
> Intl.NumberFormat("en", {currencyDisplay:"name", style:"currency", currency:"USD"}).format(123456.78)
"123,456.78 US dollars"