Skip to content

format_currency only ever retrieves the default locale currency format #201

Closed
@craigloftus

Description

@craigloftus

format_currency always passes None to locale.currency_formats, which means that it only supports the default currency format for the given locale.

def format_currency(number, currency, format=None, locale=LC_NUMERIC):
    locale = Locale.parse(locale)
    if not format:
        format = locale.currency_formats.get(format)
    pattern = parse_pattern(format)
    return pattern.apply(number, locale, currency=currency)

Shouldn't this be:

if not format:
    locale_format = locale.currency_formats.get(currency)
    format = locale_format or locale.currency_formats.get(None)

Which would allow me to do something simple like:

Locale('en', 'US').currency_formats['KES'] = kes_format

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