Remove Babel version workaround code

Since Babel>=1.3 is required, code to work with earlier versions
can be removed and the logic made clearer.

Change-Id: I33f358912802fb1bd49ed377d974af9e213b9257
This commit is contained in:
Brant Knudson 2014-06-06 17:09:04 -05:00
parent a92f897ebc
commit 324a99cd79

View File

@ -73,25 +73,13 @@ def get_available_languages(domain):
# NOTE(mrodden): en_US should always be available (and first in case
# order matters) since our in-line message strings are en_US
language_list = ['en_US']
# NOTE(luisg): Babel <1.0 used a function called list(), which was
# renamed to locale_identifiers() in >=1.0, the requirements master list
# requires >=0.9.6, uncapped, so defensively work with both. We can remove
# this check when the master list updates to >=1.0, and update all projects
list_identifiers = (getattr(localedata, 'list', None) or
getattr(localedata, 'locale_identifiers'))
locale_identifiers = list_identifiers()
locale_identifiers = localedata.locale_identifiers()
language_list.extend(language for language in locale_identifiers
if find(language, domain, localedir))
# NOTE(luisg): Babel>=1.0,<1.3 has a bug where some OpenStack supported
# locales (e.g. 'zh_CN', and 'zh_TW') aren't supported even though they
# are perfectly legitimate locales:
# https://github.com/mitsuhiko/babel/issues/37
# In Babel 1.3 they fixed the bug and they support these locales, but
# they are still not explicitly "listed" by locale_identifiers().
# That is why we add the locales here explicitly if necessary so that
# they are listed as supported.
# In Babel 1.3, locale_identifiers() doesn't list some OpenStack supported
# locales (e.g. 'zh_CN', and 'zh_TW') so we add the locales explicitly if
# necessary so that they are listed as supported.
aliases = {'zh': 'zh_CN',
'zh_Hant_HK': 'zh_HK',
'zh_Hant': 'zh_TW',