Blame SOURCES/yum-langpacks-0.4.2-fix-langinfo-command.patch

dfd9a3
diff -urN yum-langpacks-0.4.2.old/langpacks.py yum-langpacks-0.4.2/langpacks.py
dfd9a3
--- yum-langpacks-0.4.2.old/langpacks.py	2013-10-08 14:22:25.000000000 +0530
dfd9a3
+++ yum-langpacks-0.4.2/langpacks.py	2013-11-15 14:13:33.966937576 +0530
dfd9a3
@@ -56,7 +56,7 @@
dfd9a3
 
dfd9a3
 langs = []
dfd9a3
 langinstalled = []
dfd9a3
-
dfd9a3
+whitelisted_locales = ['en_AU', 'en_CA', 'en_GB', 'pt_BR', 'pt_PT', 'zh_CN', 'zh_TW']
dfd9a3
 conditional_pkgs = {}
dfd9a3
 
dfd9a3
 def _setup_conditional_pkgs(repos):
dfd9a3
@@ -127,7 +127,7 @@
dfd9a3
 		      if lname not in skip_pkg_list:
dfd9a3
 		           langlist.append(lname)
dfd9a3
 
dfd9a3
-    return langlist
dfd9a3
+    return (seen, langlist)
dfd9a3
 
dfd9a3
 def lc_to_langname(lc):
dfd9a3
     return langtable.language_name(languageId=lc, languageIdQuery="en").encode("UTF-8")
dfd9a3
@@ -297,6 +297,35 @@
dfd9a3
           uniq_list.append(wover)
dfd9a3
    return sorted(uniq_list)
dfd9a3
 
dfd9a3
+def get_matches_from_repo(langpack_pkgs, lang):
dfd9a3
+    avl_langpack_pkgs = []
dfd9a3
+    #Check if lang is empty, case like input mara, marat
dfd9a3
+    if len(lang) == 0:
dfd9a3
+        return avl_langpack_pkgs
dfd9a3
+    lname = lc_to_langname(lang)
dfd9a3
+    lang = "-" + lang
dfd9a3
+    for pkgs in langpack_pkgs:
dfd9a3
+        if len(lang) < 5 and lang.find("_") == -1:
dfd9a3
+            if pkgs.find(lang, len(pkgs)-len(lang), len(pkgs)) > 0 :
dfd9a3
+                avl_langpack_pkgs.append(pkgs)
dfd9a3
+            if lname:
dfd9a3
+                if pkgs.find(lname, len(pkgs)-len(lname), len(pkgs)) > 0 :
dfd9a3
+                    avl_langpack_pkgs.append(pkgs)
dfd9a3
+        if len(lang) > 4 and lang.find("_") != -1:
dfd9a3
+            mainlang = lang[0:lang.find("_")]
dfd9a3
+            if pkgs.find(lang, len(pkgs)-len(lang), len(pkgs)) > 0 :
dfd9a3
+                avl_langpack_pkgs.append(pkgs)
dfd9a3
+           # if input pt_BR then show for pt and pt_BR
dfd9a3
+            # if input zh_CN then show for zh and zh_CN
dfd9a3
+            elif pkgs.find(mainlang, len(pkgs)-len(mainlang), len(pkgs)) > 0 :
dfd9a3
+                avl_langpack_pkgs.append(pkgs)
dfd9a3
+
dfd9a3
+            if lname:
dfd9a3
+                if pkgs.find(lname, len(pkgs)-len(lname), len(pkgs)) > 0 :
dfd9a3
+                    avl_langpack_pkgs.append(pkgs)
dfd9a3
+
dfd9a3
+    return sorted(avl_langpack_pkgs)
dfd9a3
+
dfd9a3
 def get_matches_from_ts(lang, base = None):
dfd9a3
     yb = base
dfd9a3
     sack = base.pkgSack
dfd9a3
@@ -574,13 +603,27 @@
dfd9a3
     def doCommand(self, base, basecmd, extcmds):
dfd9a3
         base.repos.doSetup()
dfd9a3
         _setup_conditional_pkgs(base.repos.listEnabled())
dfd9a3
+        (langpack_pkgs, ra_list) = read_available_langpacks(base)
dfd9a3
+
dfd9a3
         for lang in extcmds:
dfd9a3
-	    print "Language-Id={0}".format(lang)
dfd9a3
-	    if len(lang) > 3 and lang.find("_") == -1:
dfd9a3
-                list_pkgs = get_matches_from_ts(langname_to_lc(lang), base)
dfd9a3
+            print "Language-Id={0}".format(lang)
dfd9a3
+            if len(lang) == 1:
dfd9a3
+                print "Not a valid input"
dfd9a3
+                return 0, [""]
dfd9a3
+            # Case to handle input like zh_CN, pt_BR
dfd9a3
+            elif lang in whitelisted_locales and len(lang) > 3 and lang.find("_") != -1:
dfd9a3
+                list_pkgs = get_matches_from_repo(langpack_pkgs, lang)
dfd9a3
+            # Case for full language name input like Japanese
dfd9a3
+            elif len(lang) > 3 and lang.find("_") == -1:
dfd9a3
+                list_pkgs = get_matches_from_repo(langpack_pkgs, langname_to_lc(lang))
dfd9a3
+            # General case to handle input like ja, ru, fr, it
dfd9a3
             else:
dfd9a3
-	        list_pkgs = get_matches_from_ts(lang, base)
dfd9a3
-	    for pkg in set(list_pkgs):
dfd9a3
+                if lang.find("_") == -1:
dfd9a3
+                     list_pkgs = get_matches_from_repo(langpack_pkgs, lang)
dfd9a3
+                # Case to not process mr_IN or mai_IN locales
dfd9a3
+                else:
dfd9a3
+                     list_pkgs = []
dfd9a3
+            for pkg in list_pkgs:
dfd9a3
 		print "  " + pkg
dfd9a3
 	    if len(list_pkgs) == 0:
dfd9a3
                  print "No langpacks to show for languages: {0}".format(lang)
dfd9a3
@@ -603,8 +646,8 @@
dfd9a3
         base.repos.doSetup()
dfd9a3
         _setup_conditional_pkgs(base.repos.listEnabled())
dfd9a3
 
dfd9a3
-        list = read_available_langpacks(base)
dfd9a3
-        langlist = get_unique_language_names(list)
dfd9a3
+        (language_packs, ra_list) = read_available_langpacks(base)
dfd9a3
+        langlist = get_unique_language_names(ra_list)
dfd9a3
 
dfd9a3
         if not extcmds:
dfd9a3
             print "Displaying all available language:-"