Open jenstroeger opened 4 years ago
All the locale data in Babel comes from the Unicode CLDR (at least until some planned custom overlays etc. are implemented).
I couldn't find an issue for Pāli in the CLDR issue tracker, so you may wish to follow the procedure to request a new locale.
Thanks for the tip, @akx! I’ve opened CLDR-13555, and I guess we’ll just have to wait and see what happens next?
Feel free to close this one.
@akx, hmm, looking at en.xml of the CLDR then both Pāli (pi
) and Latin (la
) are defined, yet:
>>> import babel
>>> babel.__version__
'2.8.0'
>>> babel.Locale('la')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/…/lib/python3.7/site-packages/babel/core.py", line 168, in __init__
raise UnknownLocaleError(identifier)
babel.core.UnknownLocaleError: unknown locale 'la'
>>> babel.Locale('pi')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/…/lib/python3.7/site-packages/babel/core.py", line 168, in __init__
raise UnknownLocaleError(identifier)
babel.core.UnknownLocaleError: unknown locale 'pi'
What am I missing here?
You're looking at the list of language names in English, which is generally accessible with Locale.get_language_name()
... but that API unfortunately doesn't work for languages that aren't available for Babel, so you'd have to look at the underlying languages
dict instead to access that data:
>>> en = babel.Locale.parse("en")
>>> en.languages.get('pi')
'Pali'
>>> en.languages.get('la')
'Latin'
@akx, thank you! Is the display name available as well? From the docs:
Locales itself can be used to describe the locale itself or other locales.
So I guess without having a Locale object for Pāli or Sanskrit I won’t be able to access their respective display names?
Well, you could compose something akin to a display name from a language name and territory name (l.languages
and l.territories
), if you know the territory that language is spoken in.
@jenstroeger CLDR ticket was closed due to no further data
@srl295, just responded.
BTW, I came across similar issues with languages like Cree or Sanskrit.
So,
pi
is the ISO_639-1 language code for the Pāli language, yetI’m not sure what’s required to add a new locale here, but would it be possible to add Pāli? Happy to submit a PR if somebody can give me pointers.