babel
babel copied to clipboard
babel.core.UnknownLocaleError: unknown locale 'und_BQ'
Overview Description
Steps to Reproduce
- Try to initialize a locale with undetermined language using BQ (Caribbean Netherlands) country code, e.g.
und_BQ
Actual Results
This causes an error babel.core.UnknownLocaleError: unknown locale 'und_BQ'
Expected Results
I would expect this to succeed and use the only matching locale, nl_BQ, instead when formatting dates
Reproducibility
Additional Information
I think implicitly finding nl_BQ for und_BQ would be unexpected behavior.
If you have an und_XX locale, you can use get_territory_language_info() to find which language(s) are spoken in XX, and figure out which one is relevant for your users:
>>> import babel.languages as bl
>>> bl.get_territory_language_info("BQ")
{'pap': {'population_percent': 81.0, 'official_status': None}, 'nl': {'population_percent': 8.0, 'official_status': 'official'}}
>>>