Re: [PATCH v2] Use correct grammar in diffstat summary line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 01, 2012 at 01:26:43PM -0800, Junio C Hamano wrote:
> Nice.  Will queue

Please also squash this in (resend looks ugly and it's hard to point
out changes). It makes the code look less ugly, use Q_() for gettext
poisoning and revert am input text back as Jonathan suggested.

I take it --summary is un-i18n-able, should we introduce.. umm..
--nice-summary or something that can support i18n?

-- 8< --
diff --git a/diff.c b/diff.c
index 5f3ce97..07c94f2 100644
--- a/diff.c
+++ b/diff.c
@@ -1325,6 +1325,7 @@ static void fill_print_name(struct diffstat_file *file)
 int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
 {
 	struct strbuf sb = STRBUF_INIT;
+	const char *fmt;
 	int ret;
 
 	if (!files) {
@@ -1332,10 +1333,8 @@ int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
 		return fputs(_(" 0 files changed\n"), fp);
 	}
 
-	strbuf_addf(&sb,
-		    ngettext(" %d file changed", " %d files changed",
-			     files),
-		    files);
+	fmt = Q_(" %d file changed", " %d files changed", files);
+	strbuf_addf(&sb, fmt, files);
 
 	/*
 	 * For binary diff, the caller may want to print "x files
@@ -1346,25 +1345,17 @@ int print_stat_summary(FILE *fp, int files, int insertions, int deletions)
 	 * but nothing about added/removed lines? Is this a bug in Git?").
 	 */
 	if (insertions || deletions == 0) {
-		strbuf_addf(&sb,
-			    /*
-			     * TRANSLATORS: "+" in (+) is a line addition marker;
-			     * do not translate it.
-			     */
-			    ngettext(", %d insertion(+)", ", %d insertions(+)",
-				     insertions),
-			    insertions);
+		/* TRANSLATORS: "+" in (+) is a line addition marker,
+		   do not translate it */
+		fmt = Q_(", %d insertion(+)", ", %d insertions(+)", insertions);
+		strbuf_addf(&sb, fmt, insertions);
 	}
 
 	if (deletions || insertions == 0) {
-		strbuf_addf(&sb,
-			    /*
-			     * TRANSLATORS: "-" in (-) is a line removal marker;
-			     * do not translate it.
-			     */
-			    ngettext(", %d deletion(-)", ", %d deletions(-)",
-				     deletions),
-			    deletions);
+		/* TRANSLATORS: "-" in (-) is a line removal marker,
+		   do not translate it */
+		fmt = Q_(", %d deletion(-)", ", %d deletions(-)", deletions);
+		strbuf_addf(&sb, fmt, deletions);
 	}
 	strbuf_addch(&sb, '\n');
 	ret = fputs(sb.buf, fp);
diff --git a/t/t0023-crlf-am.sh b/t/t0023-crlf-am.sh
index 18fe27b..12a3d78 100755
--- a/t/t0023-crlf-am.sh
+++ b/t/t0023-crlf-am.sh
@@ -12,7 +12,7 @@ Subject: test1
 
 ---
  foo |    1 +
- 1 file changed, 1 insertion(+)
+ 1 files changed, 1 insertions(+)
  create mode 100644 foo
 
 diff --git a/foo b/foo
-- 8< --

-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]