Skip to content

Validation / normalization of locales and currencies differ in behavior #521

@svisser

Description

@svisser

Babel 2.5.0

For currencies the functions babel.numbers.is_currency and babel.numbers.normalize_currency accept quite a few values (None, strings, numbers, lists, sets) and return the expected result (a boolean or a string).

The functions babel.localedata.normalize_locale and babel.localedata.exists raise an exception in most cases except when a string is provided.

It would be nice if these functions behaved the same way (at least for None?) so that the following approach can be used:

my_locale = babel.localedata.normalize_locale(my_locale)
my_currency = babel.numbers.normalize_currency(my_currency)

# at this point, the values are correct strings or None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions