Skip to content

Implement currency formatting with long display names.  #578

@spookylukey

Description

@spookylukey

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:

  1. What should the API be? An extra parameter to format_currency? A new format_type (this risks clashing with other format types already defined)?

  2. It looks like this would require data not currently available in the pickled locale data. Specifically it requires the unitPattern data. I'm not sure how to go about adding this - apart from the import_cldr.py script, 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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions