[Yum-devel] [PATCH 1/2] Convert cli.py to use P_ for plural string handling

Ville-Pekka Vainio vpivaini at cs.helsinki.fi
Mon Nov 16 16:35:25 UTC 2009


Use P_ for plural strings, so they can be properly translated.
---
 cli.py |   42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/cli.py b/cli.py
index 89e4fe8..8342a37 100644
--- a/cli.py
+++ b/cli.py
@@ -39,6 +39,7 @@ import yum.misc
 import yum.plugins
 from rpmUtils.arch import isMultiLibArch
 from yum import _
+from yum import P_
 from yum.rpmtrans import RPMTransaction
 import signal
 import yumcommands
@@ -553,7 +554,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         hiend = self.term.MODE['normal']
         if matches.available:
             self.verbose_logger.log(yum.logginglevels.INFO_2,
-                _('Package(s) %s%s%s available, but not installed.'),
+                P_('Package %s%s%s available, but not installed.',
+                   'Packages %s%s%s available, but not installed.', len(arg)),
                                     hibeg, arg, hiend)
             return
 
@@ -561,7 +563,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         matches = self.doPackageLists(patterns=[arg], ignore_case=True)
         if not matches.installed and matches.available:
             self.verbose_logger.log(yum.logginglevels.INFO_2,
-                _('Package(s) %s%s%s available, but not installed.'),
+                P_('Package %s%s%s available, but not installed.'
+                   'Packages %s%s%s available, but not installed.', len(arg)),
                                     hibeg, arg, hiend)
             return
         matches = set(map(lambda x: x.name, matches.installed))
@@ -603,7 +606,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                                         self.term.MODE['normal'])
                 self._maybeYouMeant(arg)
         if len(self.tsInfo) > oldcount:
-            return 2, [_('Package(s) to install')]
+            change = len(self.tsInfo) - oldcount
+            msg = P_('%d package to install',
+                     '%d packages to install', change) % change
+            return 2, [msg]
         return 0, [_('Nothing to do')]
         
     def updatePkgs(self, userlist, quiet=0):
@@ -637,7 +643,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
         if len(self.tsInfo) > oldcount:
             change = len(self.tsInfo) - oldcount
-            msg = _('%d packages marked for Update') % change
+            msg = P_('%d package marked for update',
+                    '%d packages marked for update', change) % change
             return 2, [msg]
         else:
             return 0, [_('No Packages marked for Update')]
@@ -654,7 +661,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         
         if len(self.tsInfo) > oldcount:
             change = len(self.tsInfo) - oldcount
-            msg = _('%d packages marked for removal') % change
+            msg = P_('%d package marked for removal',
+                     '%d packages marked for removal', change) % change
             return 2, [msg]
         else:
             return 0, [_('No Packages marked for removal')]
@@ -681,7 +689,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                                         self.term.MODE['normal'])
                 self._maybeYouMeant(arg)
         if len(self.tsInfo) > oldcount:
-            return 2, [_('Package(s) to downgrade')]
+            change = len(self.tsInfo) - oldcount
+            msg = P_('%d package to downgrade',
+                    '%d packages to downgrade', change) % change
+            return 2, [msg]
         return 0, [_('Nothing to do')]
         
     def reinstallPkgs(self, userlist):
@@ -714,7 +725,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
                 assert False, "Shouldn't happen, but just in case"
                 self.verbose_logger.log(yum.logginglevels.INFO_2, e)
         if len(self.tsInfo) > oldcount:
-            return 2, [_('Package(s) to reinstall')]
+            change = len(self.tsInfo) - oldcount
+            msg = P_('%d package to reinstall',
+                    '%d packages to reinstall', change) % change
+            return 2, [msg]
         return 0, [_('Nothing to do')]
 
     def localInstall(self, filelist, updateonly=0):
@@ -730,13 +744,17 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
             return 0, [_('No Packages Provided')]
 
         installing = False
+        count = 0
         for pkg in filelist:
             txmbrs = self.installLocal(pkg, updateonly=updateonly)
+            count += len(txmbrs)
             if txmbrs:
                 installing = True
 
         if installing:
-            return 2, [_('Package(s) to install')]
+            msg = P_('%d package to install',
+                     '%d packages to install', count) % count
+            return 2, [msg]
         return 0, [_('Nothing to do')]
 
     def returnPkgLists(self, extcmds, installed_available=False):
@@ -1000,7 +1018,9 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         if not pkgs_used:
             return 0, [_('No packages in any requested group available to install or update')]
         else:
-            return 2, [_('%d Package(s) to Install') % len(pkgs_used)]
+            msg = P_('%d package to install',
+                     '%d packages to install', len(pkgs_used))
+            return 2, [msg % len(pkgs_used)]
 
     def removeGroups(self, grouplist):
         """Remove only packages of the named group(s). Do not recurse."""
@@ -1018,7 +1038,9 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         if not pkgs_used:
             return 0, [_('No packages to remove from groups')]
         else:
-            return 2, [_('%d Package(s) to remove') % len(pkgs_used)]
+            msg = P_('%d package to remove',
+                     '%d packages to remove', len(pkgs_used))
+            return 2, [msg % len(pkgs_used)]
 


-- 
1.6.5.2




More information about the Yum-devel mailing list