[master][PATCH] Search for all translations, not only one per langauge (#1001446)
Vratislav Podzimek
vpodzime at redhat.com
Thu Aug 29 12:18:29 UTC 2013
There are often more translations for various language-territory combinations.
E.g. en_US and en_GB or zh_TW and zh_CN etc.
Related: rhbz#1000715
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/localization.py | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py
index 1997ac0..fc334b7 100644
--- a/pyanaconda/localization.py
+++ b/pyanaconda/localization.py
@@ -228,20 +228,21 @@ def get_available_translations(domain=None, localedir=None):
messagefiles = sorted(glob.glob(localedir + "/*/LC_MESSAGES/anaconda.mo"))
trans_gen = (path.split(os.path.sep)[-3] for path in messagefiles)
- # usually there are no message files for en
- langs = {"en"}
+ yielded_locales = {"en_US.UTF-8"}
yield "en_US.UTF-8"
for trans in trans_gen:
parts = parse_langcode(trans)
- lang = parts.get("language", "")
- if lang and lang not in langs:
- langs.add(lang)
- locales = get_language_locales(lang)
- if not locales:
- continue
-
- # take the first locale (with highest rank) for the language
+ if not parts:
+ continue
+
+ locales = get_language_locales(trans)
+ if not locales:
+ continue
+
+ # take the first locale (with highest rank) for the language
+ if locales[0] not in yielded_locales:
+ yielded_locales.add(locales[0])
yield locales[0]
def get_language_locales(lang):
--
1.7.11.7
More information about the anaconda-patches
mailing list