From: David Kalnischkies <kalnischkies@gmail.com>
Date: Mon, 15 Feb 2010 12:02:27 +0000 (+0100)
Subject: * buildlib/apti18n.h.in, po/makefile:
X-Git-Tag: 0.8.0~9^2~64^2~20^2~16
X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/d44b437bd2897bf7fbfbde07a4511c6f7b9ef6a2

* buildlib/apti18n.h.in, po/makefile:
  - add ngettext support with P_()
---

diff --git a/buildlib/apti18n.h.in b/buildlib/apti18n.h.in
index e7beceb09..6928d626c 100644
--- a/buildlib/apti18n.h.in
+++ b/buildlib/apti18n.h.in
@@ -11,8 +11,10 @@
 # include <libintl.h>
 # ifdef APT_DOMAIN
 #   define _(x) dgettext(APT_DOMAIN,x)
+#   define P_(msg,plural,n) dngettext(APT_DOMAIN,msg,plural,n)
 # else
 #   define _(x) gettext(x)
+#   define P_(msg,plural,n) ngettext(msg,plural,n)
 # endif
 # define N_(x) x
 #else
@@ -21,5 +23,6 @@
 # define textdomain(a)
 # define bindtextdomain(a, b)
 # define _(x) x
+# define P_(msg,plural,n) (n == 1 ? msg : plural)
 # define N_(x) x
 #endif
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 216383bc6..c8c733716 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1526,10 +1526,9 @@ bool DoAutomaticRemove(CacheFile &Cache)
 	    // only show stuff in the list that is not yet marked for removal
 	    if(Cache[Pkg].Delete() == false) 
 	    {
+	       ++autoRemoveCount;
 	       // we don't need to fill the strings if we don't need them
-	       if (smallList == true)
-		  ++autoRemoveCount;
-	       else
+	       if (smallList == false)
 	       {
 		 autoremovelist += string(Pkg.Name()) + " ";
 		 autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
@@ -1542,9 +1541,12 @@ bool DoAutomaticRemove(CacheFile &Cache)
    if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0))
    {
       if (smallList == false)
-	 ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
+	 ShowList(c1out, P_("The following package is automatically installed and is no longer required:",
+	          "The following packages were automatically installed and are no longer required:",
+	          autoRemoveCount), autoremovelist, autoremoveversions);
       else
-	 ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount);
+	 ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n",
+	          "%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount);
       c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl;
    }
    // Now see if we had destroyed anything (if we had done anything)
diff --git a/debian/changelog b/debian/changelog
index 948846a6c..f328b11a7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,6 +28,8 @@ apt (0.7.26) UNRELEASED; urgency=low
   * apt-pkg/deb/dpkgpm.cc:
     - stdin redirected to /dev/null takes all CPU (Closes: #569488)
       Thanks to Aurelien Jarno for providing (again) a patch!
+  * buildlib/apti18n.h.in, po/makefile:
+    - add ngettext support with P_()
 
   [ Ivan Masár ]
   * Slovak translation update. Closes: #568294
diff --git a/po/makefile b/po/makefile
index 07dc51c07..9f8b7b22e 100644
--- a/po/makefile
+++ b/po/makefile
@@ -37,6 +37,7 @@ $(POTFILES) : $(PO)/%.pot :
 	cat $(PO)/domains/$*/*.srclist > $(PO)/POTFILES_$*.in
 	$(XGETTEXT) --default-domain=$* --directory=$(BASE) \
 	  --add-comments --foreign --keyword=_ --keyword=N_ \
+	  --keyword=P_:1,2 \
 	  --files-from=$(PO)/POTFILES_$*.in -o $(PO)/domains/$*/c.pot
 	rm -f $(PO)/POTFILES_$*.in
 	$(MSGCOMM) --more-than=0 $(PO)/domains/$*/c.pot $(PO)/domains/$*/sh.pot --output=$@