Closed mauritsvanrees closed 7 years ago
If it's just to get the list of languages and their codes, there is https://pypi.python.org/pypi/iso-639 or https://pypi.python.org/pypi/pycountry that could be a better base probably.
Yes, we only need a mapping from language code to language name. So one of those packages could be good. iso-639
has the benefit of being much smaller. It might actually be good for plone.i18n
itself to start using one of these packages.
But instead, we could simply do a conditional import of plone.i18n
. Currently, when a language code is not found in the plone.i18n
definitions, we fall back to using the Language-Name
header in the po file. That is a pretty good fallback, which we can use when plone.i18n
is not importable. It also shows po files that have no proper Language-Name
header.
For those wondering: the only place where this is used, is in the list
command. To try it out, go to a locales directory, and type i18ndude list -p plone
(where plone
is the domain name you want).
We require
plone.i18n
for some statistics. On the master branch, this package requiresProducts.CMFPlone
. See this commit. We don't want to pull in all of Plone.We only use
plone.i18n
in two lines. ThegetLanguages
function that we call, simply delivers a list of languages. I don't think this list changes much between Plone versions. We could copy what we need intoi18ndude
itself.We can still try the import, and if it fails, we use our own list.
Maybe what we need (seemingly only a mapping between say 'nl' and 'Dutch') is in a small other package that we could use.