diff options
author | WangBinbin <bbwang5827@fiberhome.com> | 2017-02-16 09:11:45 +0800 |
---|---|---|
committer | WangBinbin <bbwang5827@fiberhome.com> | 2017-02-20 02:11:01 +0800 |
commit | 108d2bb7a986ced5014e43da5cda29dae5d15ec1 (patch) | |
tree | 6ceaca659a83ee92723fdbf709e91bc1b5f4e574 | |
parent | b95634c8ca732810bb0f9d4df6f3eeabef7aa552 (diff) | |
download | oslo-i18n-108d2bb7a986ced5014e43da5cda29dae5d15ec1.tar.gz |
Fix wrong response with language zh-TW.
When request OpenStack service with zh-TW, the response is zh-CN.
Change-Id: I00601dec28adbef05e9ab0ebb6d291d0eee8becb
Closes-Bug: #1665255
-rw-r--r-- | oslo_i18n/_gettextutils.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/oslo_i18n/_gettextutils.py b/oslo_i18n/_gettextutils.py index 8d78376..9153b36 100644 --- a/oslo_i18n/_gettextutils.py +++ b/oslo_i18n/_gettextutils.py @@ -80,10 +80,22 @@ def get_available_languages(domain): 'zh_Hant_HK': 'zh_HK', 'zh_Hant': 'zh_TW', 'fil': 'tl_PH'} - language_list.extend(alias for locale, alias in aliases.items() if (locale in language_list and alias not in language_list)) - _AVAILABLE_LANGUAGES[domain] = language_list - return copy.copy(language_list) + language_list.extend(alias for locale, alias in aliases.items() + if (locale not in language_list and + find(alias))) + + # In webob.acceptparse, the best_match is just match the first element in + # the language_list, so make the precise element in front + result = ['en_US'] + for i in language_list[1:]: + if '_' in i: + result.insert(1, i) + else: + result.append(i) + + _AVAILABLE_LANGUAGES[domain] = result + return copy.copy(result) |