>>> from babel import Locale
>>> print(Locale('pt_ES').get_language_name('en_US'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/anaconda3/envs/poetry/lib/python3.9/site-packages/babel/core.py", line 204, in __init__
raise UnknownLocaleError(identifier)
babel.core.UnknownLocaleError: unknown locale 'pt_ES'
>>> Locale('pt').get_language_name('en_US')
'Portuguese'
Both mr_IN and pt_ES can't be found while their respective Locale exists for the language itself i.e. mr or pt so I'd expect both of them to either return None or both of them to throw an UnknownLocaleError.
There seems to be inconsistency when
UnknownLocaleError
is thrown versus whenNone
is returned. See below example:Both
mr_IN
andpt_ES
can't be found while their respective Locale exists for the language itself i.e.mr
orpt
so I'd expect both of them to either returnNone
or both of them to throw anUnknownLocaleError
.