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

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