All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i18n 00/11] Mark more strings for translation
@ 2012-04-16 12:49 Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended Nguyễn Thái Ngọc Duy
                   ` (11 more replies)
  0 siblings, 12 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

This series marks the following for translations

 - relative dates
 - git-help (and provide support for translating parseopt)
 - git-remote
 - git-index-pack
 - git-apply
 - git-bundle

Except git-help, other commands are chosen because they handle plural
form and I'd like to reuse gettext for that. There are a few conflicts
with topics on pu, but seem easy to resolve.

Jonathan Nieder (1):
  i18n: mark relative dates for translation

Nguyễn Thái Ngọc Duy (10):
  Add three convenient format printing functions with \n automatically appended
  i18n: parseopt: lookup help and argument translations when showing usage
  i18n: help: mark parseopt strings for translation
  i18n: help: mark strings for translation
  i18n: make warn_dangling_symref() automatically append \n
  i18n: remote: mark strings for translation
  i18n: apply: mark strings for translation
  i18n: apply: update say_patch_name to give translators complete sentence
  i18n: index-pack: mark strings for translation
  i18n: bundle: mark strings for translation

 Makefile             |    2 +-
 builtin/apply.c      |  259 ++++++++++++++++++++++++++------------------------
 builtin/fetch.c      |    4 +-
 builtin/help.c       |   58 ++++++------
 builtin/index-pack.c |  117 ++++++++++++-----------
 builtin/remote.c     |  252 ++++++++++++++++++++++++++-----------------------
 bundle.c             |   38 ++++----
 cache.h              |    6 +-
 date.c               |   95 +++++++++++--------
 generate-cmdlist.sh  |    2 +-
 git.c                |    2 +-
 help.c               |   34 ++++---
 parse-options.c      |   15 ++--
 parse-options.h      |    7 +-
 refs.c               |    1 +
 strbuf.c             |   33 +++++++
 strbuf.h             |    7 ++
 test-date.c          |    7 +-
 18 files changed, 517 insertions(+), 422 deletions(-)

-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-16 17:26   ` Jonathan Nieder
  2012-04-17  8:12   ` Erik Faye-Lund
  2012-04-16 12:49 ` [PATCH i18n 02/11] i18n: mark relative dates for translation Nguyễn Thái Ngọc Duy
                   ` (10 subsequent siblings)
  11 siblings, 2 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

These functions are helpful when we do not want to expose \n to
translators. For example

    printf("hello world\n");

can be converted to

    printf_ln(_("hello world"));
---
 strbuf.c |   33 +++++++++++++++++++++++++++++++++
 strbuf.h |    7 +++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/strbuf.c b/strbuf.c
index 5135d59..9fbc75c 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -464,3 +464,36 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
 {
 	strbuf_add_urlencode(sb, s, strlen(s), reserved);
 }
+
+void strbuf_addf_ln(struct strbuf *sb, const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	strbuf_vaddf(sb, fmt, ap);
+	va_end(ap);
+	strbuf_addch(sb, '\n');
+}
+
+int printf_ln(const char *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	va_start(ap, fmt);
+	ret = vprintf(fmt, ap);
+	va_end(ap);
+	if (ret >= 0)
+		ret += printf("\n");
+	return ret;
+}
+
+int fprintf_ln(FILE *fp, const char *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	va_start(ap, fmt);
+	ret = vfprintf(fp, fmt, ap);
+	va_end(ap);
+	if (ret >= 0)
+		ret += fprintf(fp, "\n");
+	return ret;
+}
diff --git a/strbuf.h b/strbuf.h
index 3effaa8..b888d40 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -99,6 +99,8 @@ __attribute__((format (printf,2,3)))
 extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
 __attribute__((format (printf,2,0)))
 extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
+__attribute__((format (printf,2,3)))
+extern void strbuf_addf_ln(struct strbuf *sb, const char *fmt, ...);
 
 extern void strbuf_add_lines(struct strbuf *sb, const char *prefix, const char *buf, size_t size);
 
@@ -129,4 +131,9 @@ extern void strbuf_add_urlencode(struct strbuf *, const char *, size_t,
 extern void strbuf_addstr_urlencode(struct strbuf *, const char *,
 				    int reserved);
 
+__attribute__((format (printf,1,2)))
+extern int printf_ln(const char *fmt, ...);
+__attribute__((format (printf,2,3)))
+extern int fprintf_ln(FILE *fp, const char *fmt, ...);
+
 #endif /* STRBUF_H */
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 02/11] i18n: mark relative dates for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage Nguyễn Thái Ngọc Duy
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git; +Cc: Ævar Arnfjörð, Jiang Xin, Jonathan Nieder

From: Jonathan Nieder <jrnieder@gmail.com>

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 cache.h     |    6 +--
 date.c      |   95 ++++++++++++++++++++++++++++++++++------------------------
 test-date.c |    7 ++--
 3 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/cache.h b/cache.h
index a8aceb5..aa9f8f9 100644
--- a/cache.h
+++ b/cache.h
@@ -906,10 +906,8 @@ enum date_mode {
 };
 
 const char *show_date(unsigned long time, int timezone, enum date_mode mode);
-const char *show_date_relative(unsigned long time, int tz,
-			       const struct timeval *now,
-			       char *timebuf,
-			       size_t timebuf_size);
+void show_date_relative(unsigned long time, int tz, const struct timeval *now,
+			struct strbuf *timebuf);
 int parse_date(const char *date, char *buf, int bufsize);
 int parse_date_basic(const char *date, unsigned long *timestamp, int *offset);
 void datestamp(char *buf, int bufsize);
diff --git a/date.c b/date.c
index a5055ca..1fdcf7c 100644
--- a/date.c
+++ b/date.c
@@ -86,83 +86,98 @@ static int local_tzoffset(unsigned long time)
 	return offset * eastwest;
 }
 
-const char *show_date_relative(unsigned long time, int tz,
+void show_date_relative(unsigned long time, int tz,
 			       const struct timeval *now,
-			       char *timebuf,
-			       size_t timebuf_size)
+			       struct strbuf *timebuf)
 {
 	unsigned long diff;
-	if (now->tv_sec < time)
-		return "in the future";
+	if (now->tv_sec < time) {
+		strbuf_addstr(timebuf, _("in the future"));
+		return;
+	}
 	diff = now->tv_sec - time;
 	if (diff < 90) {
-		snprintf(timebuf, timebuf_size, "%lu seconds ago", diff);
-		return timebuf;
+		strbuf_addf(timebuf,
+			 Q_("%lu second ago", "%lu seconds ago", diff), diff);
+		return;
 	}
 	/* Turn it into minutes */
 	diff = (diff + 30) / 60;
 	if (diff < 90) {
-		snprintf(timebuf, timebuf_size, "%lu minutes ago", diff);
-		return timebuf;
+		strbuf_addf(timebuf,
+			 Q_("%lu minute ago", "%lu minutes ago", diff), diff);
+		return;
 	}
 	/* Turn it into hours */
 	diff = (diff + 30) / 60;
 	if (diff < 36) {
-		snprintf(timebuf, timebuf_size, "%lu hours ago", diff);
-		return timebuf;
+		strbuf_addf(timebuf,
+			 Q_("%lu hour ago", "%lu hours ago", diff), diff);
+		return;
 	}
 	/* We deal with number of days from here on */
 	diff = (diff + 12) / 24;
 	if (diff < 14) {
-		snprintf(timebuf, timebuf_size, "%lu days ago", diff);
-		return timebuf;
+		strbuf_addf(timebuf,
+			 Q_("%lu day ago", "%lu days ago", diff), diff);
+		return;
 	}
 	/* Say weeks for the past 10 weeks or so */
 	if (diff < 70) {
-		snprintf(timebuf, timebuf_size, "%lu weeks ago", (diff + 3) / 7);
-		return timebuf;
+		strbuf_addf(timebuf,
+			 Q_("%lu week ago", "%lu weeks ago", (diff + 3) / 7),
+			 (diff + 3) / 7);
+		return;
 	}
 	/* Say months for the past 12 months or so */
 	if (diff < 365) {
-		snprintf(timebuf, timebuf_size, "%lu months ago", (diff + 15) / 30);
-		return timebuf;
+		strbuf_addf(timebuf,
+			 Q_("%lu month ago", "%lu months ago", (diff + 15) / 30),
+			 (diff + 15) / 30);
+		return;
 	}
 	/* Give years and months for 5 years or so */
 	if (diff < 1825) {
 		unsigned long totalmonths = (diff * 12 * 2 + 365) / (365 * 2);
 		unsigned long years = totalmonths / 12;
 		unsigned long months = totalmonths % 12;
-		int n;
-		n = snprintf(timebuf, timebuf_size, "%lu year%s",
-				years, (years > 1 ? "s" : ""));
-		if (months)
-			snprintf(timebuf + n, timebuf_size - n,
-					", %lu month%s ago",
-					months, (months > 1 ? "s" : ""));
-		else
-			snprintf(timebuf + n, timebuf_size - n, " ago");
-		return timebuf;
+		if (months) {
+			struct strbuf sb = STRBUF_INIT;
+			strbuf_addf(&sb, Q_("%lu year", "%lu years", years), years);
+			/* TRANSLATORS: "%s" is "<n> years" */
+			strbuf_addf(timebuf,
+				 Q_("%s, %lu month ago", "%s, %lu months ago", months),
+				 sb.buf, months);
+			strbuf_release(&sb);
+		} else
+			strbuf_addf(timebuf,
+				 Q_("%lu year ago", "%lu years ago", years), years);
+		return;
 	}
 	/* Otherwise, just years. Centuries is probably overkill. */
-	snprintf(timebuf, timebuf_size, "%lu years ago", (diff + 183) / 365);
-	return timebuf;
+	strbuf_addf(timebuf,
+		 Q_("%lu year ago", "%lu years ago", (diff + 183) / 365),
+		 (diff + 183) / 365);
 }
 
 const char *show_date(unsigned long time, int tz, enum date_mode mode)
 {
 	struct tm *tm;
-	static char timebuf[200];
+	static struct strbuf timebuf = STRBUF_INIT;
 
 	if (mode == DATE_RAW) {
-		snprintf(timebuf, sizeof(timebuf), "%lu %+05d", time, tz);
-		return timebuf;
+		strbuf_reset(&timebuf);
+		strbuf_addf(&timebuf, "%lu %+05d", time, tz);
+		return timebuf.buf;
 	}
 
 	if (mode == DATE_RELATIVE) {
 		struct timeval now;
+
+		strbuf_reset(&timebuf);
 		gettimeofday(&now, NULL);
-		return show_date_relative(time, tz, &now,
-					  timebuf, sizeof(timebuf));
+		show_date_relative(time, tz, &now, &timebuf);
+		return timebuf.buf;
 	}
 
 	if (mode == DATE_LOCAL)
@@ -171,23 +186,25 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
 	tm = time_to_tm(time, tz);
 	if (!tm)
 		return NULL;
+
+	strbuf_reset(&timebuf);
 	if (mode == DATE_SHORT)
-		sprintf(timebuf, "%04d-%02d-%02d", tm->tm_year + 1900,
+		strbuf_addf(&timebuf, "%04d-%02d-%02d", tm->tm_year + 1900,
 				tm->tm_mon + 1, tm->tm_mday);
 	else if (mode == DATE_ISO8601)
-		sprintf(timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d",
+		strbuf_addf(&timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d",
 				tm->tm_year + 1900,
 				tm->tm_mon + 1,
 				tm->tm_mday,
 				tm->tm_hour, tm->tm_min, tm->tm_sec,
 				tz);
 	else if (mode == DATE_RFC2822)
-		sprintf(timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d",
+		strbuf_addf(&timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d",
 			weekday_names[tm->tm_wday], tm->tm_mday,
 			month_names[tm->tm_mon], tm->tm_year + 1900,
 			tm->tm_hour, tm->tm_min, tm->tm_sec, tz);
 	else
-		sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d",
+		strbuf_addf(&timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d",
 				weekday_names[tm->tm_wday],
 				month_names[tm->tm_mon],
 				tm->tm_mday,
@@ -195,7 +212,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
 				tm->tm_year + 1900,
 				(mode == DATE_LOCAL) ? 0 : ' ',
 				tz);
-	return timebuf;
+	return timebuf.buf;
 }
 
 /*
diff --git a/test-date.c b/test-date.c
index 6bcd5b0..10afaab 100644
--- a/test-date.c
+++ b/test-date.c
@@ -7,13 +7,14 @@ static const char *usage_msg = "\n"
 
 static void show_dates(char **argv, struct timeval *now)
 {
-	char buf[128];
+	struct strbuf buf = STRBUF_INIT;
 
 	for (; *argv; argv++) {
 		time_t t = atoi(*argv);
-		show_date_relative(t, 0, now, buf, sizeof(buf));
-		printf("%s -> %s\n", *argv, buf);
+		show_date_relative(t, 0, now, &buf);
+		printf("%s -> %s\n", *argv, buf.buf);
 	}
+	strbuf_release(&buf);
 }
 
 static void parse_dates(char **argv, struct timeval *now)
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 02/11] i18n: mark relative dates for translation Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-16 17:54   ` Jonathan Nieder
  2012-04-16 12:49 ` [PATCH i18n 04/11] i18n: help: mark parseopt strings for translation Nguyễn Thái Ngọc Duy
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 parse-options.c |   15 +++++++--------
 parse-options.h |    7 +++++--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 850cfa7..7690de8 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -490,7 +490,7 @@ static int usage_argh(const struct option *opts, FILE *outfile)
 			s = literal ? "[%s]" : "[<%s>]";
 	else
 		s = literal ? " %s" : " <%s>";
-	return fprintf(outfile, s, opts->argh ? opts->argh : "...");
+	return fprintf(outfile, s, opts->argh ? _(opts->argh) : "...");
 }
 
 #define USAGE_OPTS_WIDTH 24
@@ -508,13 +508,12 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 	if (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)
 		fprintf(outfile, "cat <<\\EOF\n");
 
-	fprintf(outfile, "usage: %s\n", *usagestr++);
+	fprintf_ln(outfile, _("usage: %s"), _(*usagestr++));
 	while (*usagestr && **usagestr)
-		fprintf(outfile, "   or: %s\n", *usagestr++);
+		fprintf_ln(outfile, _("   or: %s"), _(*usagestr++));
 	while (*usagestr) {
-		fprintf(outfile, "%s%s\n",
-				**usagestr ? "    " : "",
-				*usagestr);
+		fprintf(outfile, "%s%s\n", **usagestr ? "    " : "",
+			_(*usagestr));
 		usagestr++;
 	}
 
@@ -528,7 +527,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 		if (opts->type == OPTION_GROUP) {
 			fputc('\n', outfile);
 			if (*opts->help)
-				fprintf(outfile, "%s\n", opts->help);
+				fprintf(outfile, "%s\n", _(opts->help));
 			continue;
 		}
 		if (!full && (opts->flags & PARSE_OPT_HIDDEN))
@@ -558,7 +557,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 			fputc('\n', outfile);
 			pad = USAGE_OPTS_WIDTH;
 		}
-		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", _(opts->help));
 	}
 	fputc('\n', outfile);
 
diff --git a/parse-options.h b/parse-options.h
index def9ced..4e59f2c 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -66,12 +66,14 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
  *
  * `argh`::
  *   token to explain the kind of argument this option wants. Keep it
- *   homogeneous across the repository.
+ *   homogeneous across the repository. Should be wrapped by N_() for
+ *   translation.
  *
  * `help`::
  *   the short help associated to what the option does.
  *   Must never be NULL (except for OPTION_END).
  *   OPTION_GROUP uses this pointer to store the group header.
+ *   Should be wrapped by N_() for translation.
  *
  * `flags`::
  *   mask of parse_opt_option_flags.
@@ -158,7 +160,8 @@ struct option {
 #define OPT_BOOLEAN OPT_COUNTUP
 
 /* parse_options() will filter out the processed options and leave the
- * non-option arguments in argv[].
+ * non-option arguments in argv[]. usagestr strings should be marked
+ * for translation with N_().
  * Returns the number of arguments left in argv[].
  */
 extern int parse_options(int argc, const char **argv, const char *prefix,
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 04/11] i18n: help: mark parseopt strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  2012-04-16 12:49 ` [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 05/11] i18n: help: mark " Nguyễn Thái Ngọc Duy
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 builtin/help.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/help.c b/builtin/help.c
index 61ff798..22756bd 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -32,17 +32,17 @@ enum help_format {
 static int show_all = 0;
 static enum help_format help_format = HELP_FORMAT_NONE;
 static struct option builtin_help_options[] = {
-	OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
-	OPT_SET_INT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
-	OPT_SET_INT('w', "web", &help_format, "show manual in web browser",
+	OPT_BOOLEAN('a', "all", &show_all, N_("print all available commands")),
+	OPT_SET_INT('m', "man", &help_format, N_("show man page"), HELP_FORMAT_MAN),
+	OPT_SET_INT('w', "web", &help_format, N_("show manual in web browser"),
 			HELP_FORMAT_WEB),
-	OPT_SET_INT('i', "info", &help_format, "show info page",
+	OPT_SET_INT('i', "info", &help_format, N_("show info page"),
 			HELP_FORMAT_INFO),
 	OPT_END(),
 };
 
 static const char * const builtin_help_usage[] = {
-	"git help [--all] [--man|--web|--info] [command]",
+	N_("git help [--all] [--man|--web|--info] [command]"),
 	NULL
 };
 
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 05/11] i18n: help: mark strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  2012-04-16 12:49 ` [PATCH i18n 04/11] i18n: help: mark parseopt strings for translation Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-18 19:30   ` Jonathan Nieder
  2012-04-16 12:49 ` [PATCH i18n 06/11] i18n: make warn_dangling_symref() automatically append \n Nguyễn Thái Ngọc Duy
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

This patch also marks most common commands' synopsis for translation
so that "git help" gives a friendly listing.
---
 Makefile            |    2 +-
 builtin/help.c      |   48 ++++++++++++++++++++++++------------------------
 generate-cmdlist.sh |    2 +-
 git.c               |    2 +-
 help.c              |   34 +++++++++++++++++++++-------------
 5 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/Makefile b/Makefile
index be1957a..34cf971 100644
--- a/Makefile
+++ b/Makefile
@@ -2282,7 +2282,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
 	--keyword=_ --keyword=N_ --keyword="Q_:1,2"
 XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell
 XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
-LOCALIZED_C := $(C_OBJ:o=c)
+LOCALIZED_C := $(C_OBJ:o=c) common-cmds.h
 LOCALIZED_SH := $(SCRIPT_SH)
 LOCALIZED_PERL := $(SCRIPT_PERL)
 
diff --git a/builtin/help.c b/builtin/help.c
index 22756bd..ab6bbf4 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -54,7 +54,7 @@ static enum help_format parse_help_format(const char *format)
 		return HELP_FORMAT_INFO;
 	if (!strcmp(format, "web") || !strcmp(format, "html"))
 		return HELP_FORMAT_WEB;
-	die("unrecognized help format '%s'", format);
+	die(_("unrecognized help format '%s'"), format);
 }
 
 static const char *get_man_viewer_info(const char *name)
@@ -82,7 +82,7 @@ static int check_emacsclient_version(void)
 	ec_process.err = -1;
 	ec_process.stdout_to_stderr = 1;
 	if (start_command(&ec_process))
-		return error("Failed to start emacsclient.");
+		return error(_("Failed to start emacsclient."));
 
 	strbuf_read(&buffer, ec_process.err, 20);
 	close(ec_process.err);
@@ -95,7 +95,7 @@ static int check_emacsclient_version(void)
 
 	if (prefixcmp(buffer.buf, "emacsclient")) {
 		strbuf_release(&buffer);
-		return error("Failed to parse emacsclient version.");
+		return error(_("Failed to parse emacsclient version."));
 	}
 
 	strbuf_remove(&buffer, 0, strlen("emacsclient"));
@@ -103,7 +103,7 @@ static int check_emacsclient_version(void)
 
 	if (version < 22) {
 		strbuf_release(&buffer);
-		return error("emacsclient version '%d' too old (< 22).",
+		return error(_("emacsclient version '%d' too old (< 22)."),
 			version);
 	}
 
@@ -121,7 +121,7 @@ static void exec_woman_emacs(const char *path, const char *page)
 			path = "emacsclient";
 		strbuf_addf(&man_page, "(woman \"%s\")", page);
 		execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
-		warning("failed to exec '%s': %s", path, strerror(errno));
+		warning(_("failed to exec '%s': %s"), path, strerror(errno));
 	}
 }
 
@@ -149,7 +149,7 @@ static void exec_man_konqueror(const char *path, const char *page)
 			path = "kfmclient";
 		strbuf_addf(&man_page, "man:%s(1)", page);
 		execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
-		warning("failed to exec '%s': %s", path, strerror(errno));
+		warning(_("failed to exec '%s': %s"), path, strerror(errno));
 	}
 }
 
@@ -158,7 +158,7 @@ static void exec_man_man(const char *path, const char *page)
 	if (!path)
 		path = "man";
 	execlp(path, "man", page, (char *)NULL);
-	warning("failed to exec '%s': %s", path, strerror(errno));
+	warning(_("failed to exec '%s': %s"), path, strerror(errno));
 }
 
 static void exec_man_cmd(const char *cmd, const char *page)
@@ -166,7 +166,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
 	struct strbuf shell_cmd = STRBUF_INIT;
 	strbuf_addf(&shell_cmd, "%s %s", cmd, page);
 	execl("/bin/sh", "sh", "-c", shell_cmd.buf, (char *)NULL);
-	warning("failed to exec '%s': %s", cmd, strerror(errno));
+	warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
 }
 
 static void add_man_viewer(const char *name)
@@ -206,8 +206,8 @@ static int add_man_viewer_path(const char *name,
 	if (supported_man_viewer(name, len))
 		do_add_man_viewer_info(name, len, value);
 	else
-		warning("'%s': path for unsupported man viewer.\n"
-			"Please consider using 'man.<tool>.cmd' instead.",
+		warning(_("'%s': path for unsupported man viewer.\n"
+			  "Please consider using 'man.<tool>.cmd' instead."),
 			name);
 
 	return 0;
@@ -218,8 +218,8 @@ static int add_man_viewer_cmd(const char *name,
 			      const char *value)
 {
 	if (supported_man_viewer(name, len))
-		warning("'%s': cmd for supported man viewer.\n"
-			"Please consider using 'man.<tool>.path' instead.",
+		warning(_("'%s': cmd for supported man viewer.\n"
+			  "Please consider using 'man.<tool>.path' instead."),
 			name);
 	else
 		do_add_man_viewer_info(name, len, value);
@@ -280,11 +280,11 @@ void list_common_cmds_help(void)
 			longest = strlen(common_cmds[i].name);
 	}
 
-	puts("The most commonly used git commands are:");
+	puts(_("The most commonly used git commands are:"));
 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
 		printf("   %s   ", common_cmds[i].name);
 		mput_char(' ', longest - strlen(common_cmds[i].name));
-		puts(common_cmds[i].help);
+		puts(_(common_cmds[i].help));
 	}
 }
 
@@ -348,7 +348,7 @@ static void exec_viewer(const char *name, const char *page)
 	else if (info)
 		exec_man_cmd(info, page);
 	else
-		warning("'%s': unknown man viewer.", name);
+		warning(_("'%s': unknown man viewer."), name);
 }
 
 static void show_man_page(const char *git_cmd)
@@ -365,7 +365,7 @@ static void show_man_page(const char *git_cmd)
 	if (fallback)
 		exec_viewer(fallback, page);
 	exec_viewer("man", page);
-	die("no man viewer handled the request");
+	die(_("no man viewer handled the request"));
 }
 
 static void show_info_page(const char *git_cmd)
@@ -373,7 +373,7 @@ static void show_info_page(const char *git_cmd)
 	const char *page = cmd_to_page(git_cmd);
 	setenv("INFOPATH", system_path(GIT_INFO_PATH), 1);
 	execlp("info", "info", "gitman", page, (char *)NULL);
-	die("no info viewer handled the request");
+	die(_("no info viewer handled the request"));
 }
 
 static void get_html_page_path(struct strbuf *page_path, const char *page)
@@ -384,7 +384,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)
 	/* Check that we have a git documentation directory. */
 	if (stat(mkpath("%s/git.html", html_path), &st)
 	    || !S_ISREG(st.st_mode))
-		die("'%s': not a documentation directory.", html_path);
+		die(_("'%s': not a documentation directory."), html_path);
 
 	strbuf_init(page_path, 0);
 	strbuf_addf(page_path, "%s/%s.html", html_path, page);
@@ -424,16 +424,16 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 	parsed_help_format = help_format;
 
 	if (show_all) {
-		printf("usage: %s\n\n", git_usage_string);
-		list_commands("git commands", &main_cmds, &other_cmds);
-		printf("%s\n", git_more_info_string);
+		printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
+		list_commands(_("git commands"), &main_cmds, &other_cmds);
+		printf("%s\n", _(git_more_info_string));
 		return 0;
 	}
 
 	if (!argv[0]) {
-		printf("usage: %s\n\n", git_usage_string);
+		printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
 		list_common_cmds_help();
-		printf("\n%s\n", git_more_info_string);
+		printf("\n%s\n", _(git_more_info_string));
 		return 0;
 	}
 
@@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 
 	alias = alias_lookup(argv[0]);
 	if (alias && !is_git_command(argv[0])) {
-		printf("`git %s' is aliased to `%s'\n", argv[0], alias);
+		printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias);
 		return 0;
 	}
 
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 1093ef4..9a4c9b9 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -16,7 +16,7 @@ do
      /^NAME/,/git-'"$cmd"'/H
      ${
 	    x
-	    s/.*git-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
+	    s/.*git-'"$cmd"' - \(.*\)/  {"'"$cmd"'", N_("\1")},/
 	    p
      }' "Documentation/git-$cmd.txt"
 done
diff --git a/git.c b/git.c
index 3805616..4486deb 100644
--- a/git.c
+++ b/git.c
@@ -13,7 +13,7 @@ const char git_usage_string[] =
 	"           <command> [<args>]";
 
 const char git_more_info_string[] =
-	"See 'git help <command>' for more information on a specific command.";
+	N_("See 'git help <command>' for more information on a specific command.");
 
 static struct startup_info git_startup_info;
 static int use_pager = -1;
diff --git a/help.c b/help.c
index 14eefc9..462e83b 100644
--- a/help.c
+++ b/help.c
@@ -217,8 +217,9 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
 
 	if (main_cmds->cnt) {
 		const char *exec_path = git_exec_path();
-		printf("available %s in '%s'\n", title, exec_path);
-		printf("----------------");
+		printf_ln(_("available %s in '%s'"), title, exec_path);
+		/* TRANSLATORS: this must align with "available %s in '%s'" */
+		printf(_("----------------"));
 		mput_char('-', strlen(title) + strlen(exec_path));
 		putchar('\n');
 		pretty_print_string_list(main_cmds, longest);
@@ -226,8 +227,12 @@ void list_commands(const char *title, struct cmdnames *main_cmds,
 	}
 
 	if (other_cmds->cnt) {
-		printf("%s available from elsewhere on your $PATH\n", title);
-		printf("---------------------------------------");
+		printf_ln(_("%s available from elsewhere on your $PATH"), title);
+		/* TRANSLATORS:
+		 * this must align with
+		 * "%s available from elsewhere on your $PATH"
+		 */
+		printf(_("---------------------------------------"));
 		mput_char('-', strlen(title));
 		putchar('\n');
 		pretty_print_string_list(other_cmds, longest);
@@ -341,7 +346,7 @@ const char *help_unknown_cmd(const char *cmd)
 	      sizeof(*main_cmds.names), levenshtein_compare);
 
 	if (!main_cmds.cnt)
-		die ("Uh oh. Your system reports no Git commands at all.");
+		die(_("Uh oh. Your system reports no Git commands at all."));
 
 	/* skip and count prefix matches */
 	for (n = 0; n < main_cmds.cnt && !main_cmds.names[n]->len; n++)
@@ -362,23 +367,26 @@ const char *help_unknown_cmd(const char *cmd)
 		const char *assumed = main_cmds.names[0]->name;
 		main_cmds.names[0] = NULL;
 		clean_cmdnames(&main_cmds);
-		fprintf(stderr, "WARNING: You called a Git command named '%s', "
-			"which does not exist.\n"
-			"Continuing under the assumption that you meant '%s'\n",
+		fprintf_ln(stderr,
+			   _("WARNING: You called a Git command named '%s', "
+			     "which does not exist.\n"
+			     "Continuing under the assumption that you meant '%s'"),
 			cmd, assumed);
 		if (autocorrect > 0) {
-			fprintf(stderr, "in %0.1f seconds automatically...\n",
+			fprintf_ln(stderr, _("in %0.1f seconds automatically..."),
 				(float)autocorrect/10.0);
 			poll(NULL, 0, autocorrect * 100);
 		}
 		return assumed;
 	}
 
-	fprintf(stderr, "git: '%s' is not a git command. See 'git --help'.\n", cmd);
+	fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);
 
 	if (SIMILAR_ENOUGH(best_similarity)) {
-		fprintf(stderr, "\nDid you mean %s?\n",
-			n < 2 ? "this": "one of these");
+		fprintf_ln(stderr,
+			   Q_("\nDid you mean this?",
+			      "\nDid you mean one of these?",
+			   n));
 
 		for (i = 0; i < n; i++)
 			fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
@@ -389,6 +397,6 @@ const char *help_unknown_cmd(const char *cmd)
 
 int cmd_version(int argc, const char **argv, const char *prefix)
 {
-	printf("git version %s\n", git_version_string);
+	printf_ln(_("git version %s"), git_version_string);
 	return 0;
 }
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 06/11] i18n: make warn_dangling_symref() automatically append \n
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  2012-04-16 12:49 ` [PATCH i18n 05/11] i18n: help: mark " Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-16 12:49 ` [PATCH i18n 07/11] i18n: remote: mark strings for translation Nguyễn Thái Ngọc Duy
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

This helps remove \n from translatable strings
---
 builtin/fetch.c  |    4 ++--
 builtin/remote.c |    4 ++--
 refs.c           |    1 +
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 65f5f9b..a8c3e4c 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -537,8 +537,8 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
 	int result = 0;
 	struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
 	const char *dangling_msg = dry_run
-		? _("   (%s will become dangling)\n")
-		: _("   (%s has become dangling)\n");
+		? _("   (%s will become dangling)")
+		: _("   (%s has become dangling)");
 
 	for (ref = stale_refs; ref; ref = ref->next) {
 		if (!dry_run)
diff --git a/builtin/remote.c b/builtin/remote.c
index fec92bc..1b03473 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1260,8 +1260,8 @@ static int prune_remote(const char *remote, int dry_run)
 	int result = 0, i;
 	struct ref_states states;
 	const char *dangling_msg = dry_run
-		? " %s will become dangling!\n"
-		: " %s has become dangling!\n";
+		? " %s will become dangling!"
+		: " %s has become dangling!";
 
 	memset(&states, 0, sizeof(states));
 	get_remote_ref_states(remote, &states, GET_REF_STATES);
diff --git a/refs.c b/refs.c
index c9f6835..54b2a03 100644
--- a/refs.c
+++ b/refs.c
@@ -395,6 +395,7 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha
 		return 0;
 
 	fprintf(d->fp, d->msg_fmt, refname);
+	fprintf(d->fp, "\n");
 	return 0;
 }
 
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 07/11] i18n: remote: mark strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  2012-04-16 12:49 ` [PATCH i18n 06/11] i18n: make warn_dangling_symref() automatically append \n Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:49 ` Nguyễn Thái Ngọc Duy
  2012-04-16 12:50 ` [PATCH i18n 08/11] i18n: apply: " Nguyễn Thái Ngọc Duy
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:49 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 builtin/remote.c |  252 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 133 insertions(+), 119 deletions(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 1b03473..db28750 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -8,18 +8,18 @@
 #include "refs.h"
 
 static const char * const builtin_remote_usage[] = {
-	"git remote [-v | --verbose]",
-	"git remote add [-t <branch>] [-m <master>] [-f] [--mirror=<fetch|push>] <name> <url>",
-	"git remote rename <old> <new>",
-	"git remote rm <name>",
-	"git remote set-head <name> (-a | -d | <branch>)",
-	"git remote [-v | --verbose] show [-n] <name>",
-	"git remote prune [-n | --dry-run] <name>",
-	"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]",
-	"git remote set-branches [--add] <name> <branch>...",
-	"git remote set-url <name> <newurl> [<oldurl>]",
-	"git remote set-url --add <name> <newurl>",
-	"git remote set-url --delete <name> <url>",
+	N_("git remote [-v | --verbose]"),
+	N_("git remote add [-t <branch>] [-m <master>] [-f] [--mirror=<fetch|push>] <name> <url>"),
+	N_("git remote rename <old> <new>"),
+	N_("git remote rm <name>"),
+	N_("git remote set-head <name> (-a | -d | <branch>)"),
+	N_("git remote [-v | --verbose] show [-n] <name>"),
+	N_("git remote prune [-n | --dry-run] <name>"),
+	N_("git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]"),
+	N_("git remote set-branches [--add] <name> <branch>..."),
+	N_("git remote set-url <name> <newurl> [<oldurl>]"),
+	N_("git remote set-url --add <name> <newurl>"),
+	N_("git remote set-url --delete <name> <url>"),
 	NULL
 };
 
@@ -95,9 +95,9 @@ static int fetch_remote(const char *name)
 		argv[1] = "-v";
 		argv[2] = name;
 	}
-	printf("Updating %s\n", name);
+	printf_ln(_("Updating %s"), name);
 	if (run_command_v_opt(argv, RUN_GIT_CMD))
-		return error("Could not fetch %s", name);
+		return error(_("Could not fetch %s"), name);
 	return 0;
 }
 
@@ -127,8 +127,8 @@ static int add_branch(const char *key, const char *branchname,
 }
 
 static const char mirror_advice[] =
-"--mirror is dangerous and deprecated; please\n"
-"\t use --mirror=fetch or --mirror=push instead";
+N_("--mirror is dangerous and deprecated; please\n"
+   "\t use --mirror=fetch or --mirror=push instead");
 
 static int parse_mirror_opt(const struct option *opt, const char *arg, int not)
 {
@@ -136,7 +136,7 @@ static int parse_mirror_opt(const struct option *opt, const char *arg, int not)
 	if (not)
 		*mirror = MIRROR_NONE;
 	else if (!arg) {
-		warning("%s", mirror_advice);
+		warning("%s", _(mirror_advice));
 		*mirror = MIRROR_BOTH;
 	}
 	else if (!strcmp(arg, "fetch"))
@@ -144,7 +144,7 @@ static int parse_mirror_opt(const struct option *opt, const char *arg, int not)
 	else if (!strcmp(arg, "push"))
 		*mirror = MIRROR_PUSH;
 	else
-		return error("unknown mirror argument: %s", arg);
+		return error(_("unknown mirror argument: %s"), arg);
 	return 0;
 }
 
@@ -182,9 +182,9 @@ static int add(int argc, const char **argv)
 		usage_with_options(builtin_remote_add_usage, options);
 
 	if (mirror && master)
-		die("specifying a master branch makes no sense with --mirror");
+		die(_("specifying a master branch makes no sense with --mirror"));
 	if (mirror && !(mirror & MIRROR_FETCH) && track.nr)
-		die("specifying branches to track makes sense only with fetch mirrors");
+		die(_("specifying branches to track makes sense only with fetch mirrors"));
 
 	name = argv[0];
 	url = argv[1];
@@ -192,11 +192,11 @@ static int add(int argc, const char **argv)
 	remote = remote_get(name);
 	if (remote && (remote->url_nr > 1 || strcmp(name, remote->url[0]) ||
 			remote->fetch_refspec_nr))
-		die("remote %s already exists.", name);
+		die(_("remote %s already exists."), name);
 
 	strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name);
 	if (!valid_fetch_refspec(buf2.buf))
-		die("'%s' is not a valid remote name", name);
+		die(_("'%s' is not a valid remote name"), name);
 
 	strbuf_addf(&buf, "remote.%s.url", name);
 	if (git_config_set(buf.buf, url))
@@ -240,7 +240,7 @@ static int add(int argc, const char **argv)
 		strbuf_addf(&buf2, "refs/remotes/%s/%s", name, master);
 
 		if (create_symref(buf.buf, buf2.buf, "remote add"))
-			return error("Could not setup master '%s'", master);
+			return error(_("Could not setup master '%s'"), master);
 	}
 
 	strbuf_release(&buf);
@@ -296,7 +296,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 		info = item->util;
 		if (type == REMOTE) {
 			if (info->remote_name)
-				warning("more than one %s", orig_key);
+				warning(_("more than one %s"), orig_key);
 			info->remote_name = xstrdup(value);
 		} else if (type == MERGE) {
 			char *space = strchr(value, ' ');
@@ -336,7 +336,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
 
 	for (i = 0; i < states->remote->fetch_refspec_nr; i++)
 		if (get_fetch_map(remote_refs, states->remote->fetch + i, &tail, 1))
-			die("Could not get fetch map for refspec %s",
+			die(_("Could not get fetch map for refspec %s"),
 				states->remote->fetch_refspec[i]);
 
 	states->new.strdup_strings = 1;
@@ -437,7 +437,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
 
 	states->push.strdup_strings = 1;
 	if (!remote->push_refspec_nr) {
-		item = string_list_append(&states->push, "(matching)");
+		item = string_list_append(&states->push, _("(matching)"));
 		info = item->util = xcalloc(sizeof(struct push_info), 1);
 		info->status = PUSH_STATUS_NOTQUERIED;
 		info->dest = xstrdup(item->string);
@@ -445,11 +445,11 @@ static int get_push_ref_states_noquery(struct ref_states *states)
 	for (i = 0; i < remote->push_refspec_nr; i++) {
 		struct refspec *spec = remote->push + i;
 		if (spec->matching)
-			item = string_list_append(&states->push, "(matching)");
+			item = string_list_append(&states->push, _("(matching)"));
 		else if (strlen(spec->src))
 			item = string_list_append(&states->push, spec->src);
 		else
-			item = string_list_append(&states->push, "(delete)");
+			item = string_list_append(&states->push, _("(delete)"));
 
 		info = item->util = xcalloc(sizeof(struct push_info), 1);
 		info->forced = spec->force;
@@ -592,19 +592,19 @@ static int migrate_file(struct remote *remote)
 	strbuf_addf(&buf, "remote.%s.url", remote->name);
 	for (i = 0; i < remote->url_nr; i++)
 		if (git_config_set_multivar(buf.buf, remote->url[i], "^$", 0))
-			return error("Could not append '%s' to '%s'",
+			return error(_("Could not append '%s' to '%s'"),
 					remote->url[i], buf.buf);
 	strbuf_reset(&buf);
 	strbuf_addf(&buf, "remote.%s.push", remote->name);
 	for (i = 0; i < remote->push_refspec_nr; i++)
 		if (git_config_set_multivar(buf.buf, remote->push_refspec[i], "^$", 0))
-			return error("Could not append '%s' to '%s'",
+			return error(_("Could not append '%s' to '%s'"),
 					remote->push_refspec[i], buf.buf);
 	strbuf_reset(&buf);
 	strbuf_addf(&buf, "remote.%s.fetch", remote->name);
 	for (i = 0; i < remote->fetch_refspec_nr; i++)
 		if (git_config_set_multivar(buf.buf, remote->fetch_refspec[i], "^$", 0))
-			return error("Could not append '%s' to '%s'",
+			return error(_("Could not append '%s' to '%s'"),
 					remote->fetch_refspec[i], buf.buf);
 	if (remote->origin == REMOTE_REMOTES)
 		path = git_path("remotes/%s", remote->name);
@@ -636,30 +636,30 @@ static int mv(int argc, const char **argv)
 
 	oldremote = remote_get(rename.old);
 	if (!oldremote)
-		die("No such remote: %s", rename.old);
+		die(_("No such remote: %s"), rename.old);
 
 	if (!strcmp(rename.old, rename.new) && oldremote->origin != REMOTE_CONFIG)
 		return migrate_file(oldremote);
 
 	newremote = remote_get(rename.new);
 	if (newremote && (newremote->url_nr > 1 || newremote->fetch_refspec_nr))
-		die("remote %s already exists.", rename.new);
+		die(_("remote %s already exists."), rename.new);
 
 	strbuf_addf(&buf, "refs/heads/test:refs/remotes/%s/test", rename.new);
 	if (!valid_fetch_refspec(buf.buf))
-		die("'%s' is not a valid remote name", rename.new);
+		die(_("'%s' is not a valid remote name"), rename.new);
 
 	strbuf_reset(&buf);
 	strbuf_addf(&buf, "remote.%s", rename.old);
 	strbuf_addf(&buf2, "remote.%s", rename.new);
 	if (git_config_rename_section(buf.buf, buf2.buf) < 1)
-		return error("Could not rename config section '%s' to '%s'",
+		return error(_("Could not rename config section '%s' to '%s'"),
 				buf.buf, buf2.buf);
 
 	strbuf_reset(&buf);
 	strbuf_addf(&buf, "remote.%s.fetch", rename.new);
 	if (git_config_set_multivar(buf.buf, NULL, NULL, 1))
-		return error("Could not remove config section '%s'", buf.buf);
+		return error(_("Could not remove config section '%s'"), buf.buf);
 	strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old);
 	for (i = 0; i < oldremote->fetch_refspec_nr; i++) {
 		char *ptr;
@@ -674,13 +674,13 @@ static int mv(int argc, const char **argv)
 				      strlen(rename.old), rename.new,
 				      strlen(rename.new));
 		} else
-			warning("Not updating non-default fetch respec\n"
-				"\t%s\n"
-				"\tPlease update the configuration manually if necessary.",
+			warning(_("Not updating non-default fetch respec\n"
+				  "\t%s\n"
+				  "\tPlease update the configuration manually if necessary."),
 				buf2.buf);
 
 		if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
-			return error("Could not append '%s'", buf.buf);
+			return error(_("Could not append '%s'"), buf.buf);
 	}
 
 	read_branches();
@@ -691,7 +691,7 @@ static int mv(int argc, const char **argv)
 			strbuf_reset(&buf);
 			strbuf_addf(&buf, "branch.%s.remote", item->string);
 			if (git_config_set(buf.buf, rename.new)) {
-				return error("Could not set '%s'", buf.buf);
+				return error(_("Could not set '%s'"), buf.buf);
 			}
 		}
 	}
@@ -713,7 +713,7 @@ static int mv(int argc, const char **argv)
 		if (!(flag & REF_ISSYMREF))
 			continue;
 		if (delete_ref(item->string, NULL, REF_NODEREF))
-			die("deleting '%s' failed", item->string);
+			die(_("deleting '%s' failed"), item->string);
 	}
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
@@ -728,7 +728,7 @@ static int mv(int argc, const char **argv)
 		strbuf_addf(&buf2, "remote: renamed %s to %s",
 				item->string, buf.buf);
 		if (rename_ref(item->string, buf.buf, buf2.buf))
-			die("renaming '%s' failed", item->string);
+			die(_("renaming '%s' failed"), item->string);
 	}
 	for (i = 0; i < remote_branches.nr; i++) {
 		struct string_list_item *item = remote_branches.items + i;
@@ -747,7 +747,7 @@ static int mv(int argc, const char **argv)
 		strbuf_addf(&buf3, "remote: renamed %s to %s",
 				item->string, buf.buf);
 		if (create_symref(buf.buf, buf2.buf, buf3.buf))
-			die("creating '%s' failed", buf.buf);
+			die(_("creating '%s' failed"), buf.buf);
 	}
 	return 0;
 }
@@ -761,7 +761,7 @@ static int remove_branches(struct string_list *branches)
 		unsigned char *sha1 = item->util;
 
 		if (delete_ref(refname, sha1, 0))
-			result |= error("Could not remove branch %s", refname);
+			result |= error(_("Could not remove branch %s"), refname);
 	}
 	return result;
 }
@@ -789,14 +789,14 @@ static int rm(int argc, const char **argv)
 
 	remote = remote_get(argv[1]);
 	if (!remote)
-		die("No such remote: %s", argv[1]);
+		die(_("No such remote: %s"), argv[1]);
 
 	known_remotes.to_delete = remote;
 	for_each_remote(add_known_remote, &known_remotes);
 
 	strbuf_addf(&buf, "remote.%s", remote->name);
 	if (git_config_rename_section(buf.buf, NULL) < 1)
-		return error("Could not remove config section '%s'", buf.buf);
+		return error(_("Could not remove config section '%s'"), buf.buf);
 
 	read_branches();
 	for (i = 0; i < branch_list.nr; i++) {
@@ -830,11 +830,11 @@ static int rm(int argc, const char **argv)
 	string_list_clear(&branches, 1);
 
 	if (skipped.nr) {
-		fprintf(stderr, skipped.nr == 1 ?
-			"Note: A branch outside the refs/remotes/ hierarchy was not removed;\n"
-			"to delete it, use:\n" :
-			"Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
-			"to delete them, use:\n");
+		fprintf_ln(stderr, skipped.nr == 1 ?
+			   _("Note: A branch outside the refs/remotes/ hierarchy was not removed;\n"
+			     "to delete it, use:") :
+			   _("Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
+			     "to delete them, use:"));
 		for (i = 0; i < skipped.nr; i++)
 			fprintf(stderr, "  git branch -d %s\n",
 				skipped.items[i].string);
@@ -886,7 +886,7 @@ static int get_remote_ref_states(const char *name,
 
 	states->remote = remote_get(name);
 	if (!states->remote)
-		return error("No such remote: %s", name);
+		return error(_("No such remote: %s"), name);
 
 	read_branches();
 
@@ -939,14 +939,14 @@ static int show_remote_info_item(struct string_list_item *item, void *cb_data)
 		const char *fmt = "%s";
 		const char *arg = "";
 		if (string_list_has_string(&states->new, name)) {
-			fmt = " new (next fetch will store in remotes/%s)";
+			fmt = _(" new (next fetch will store in remotes/%s)");
 			arg = states->remote->name;
 		} else if (string_list_has_string(&states->tracked, name))
-			arg = " tracked";
+			arg = _(" tracked");
 		else if (string_list_has_string(&states->stale, name))
-			arg = " stale (use 'git remote prune' to remove)";
+			arg = _(" stale (use 'git remote prune' to remove)");
 		else
-			arg = " ???";
+			arg = _(" ???");
 		printf("    %-*s", info->width, name);
 		printf(fmt, arg);
 		printf("\n");
@@ -987,21 +987,21 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
 	int i;
 
 	if (branch_info->rebase && branch_info->merge.nr > 1) {
-		error("invalid branch.%s.merge; cannot rebase onto > 1 branch",
+		error(_("invalid branch.%s.merge; cannot rebase onto > 1 branch"),
 			item->string);
 		return 0;
 	}
 
 	printf("    %-*s ", show_info->width, item->string);
 	if (branch_info->rebase) {
-		printf("rebases onto remote %s\n", merge->items[0].string);
+		printf_ln(_("rebases onto remote %s"), merge->items[0].string);
 		return 0;
 	} else if (show_info->any_rebase) {
-		printf(" merges with remote %s\n", merge->items[0].string);
-		also = "    and with remote";
+		printf_ln(_(" merges with remote %s"), merge->items[0].string);
+		also = _("    and with remote");
 	} else {
-		printf("merges with remote %s\n", merge->items[0].string);
-		also = "   and with remote";
+		printf_ln(_("merges with remote %s"), merge->items[0].string);
+		also = _("   and with remote");
 	}
 	for (i = 1; i < merge->nr; i++)
 		printf("    %-*s %s %s\n", show_info->width, "", also,
@@ -1043,36 +1043,43 @@ static int show_push_info_item(struct string_list_item *item, void *cb_data)
 {
 	struct show_info *show_info = cb_data;
 	struct push_info *push_info = item->util;
-	char *src = item->string, *status = NULL;
+	const char *src = item->string, *status = NULL;
 
 	switch (push_info->status) {
 	case PUSH_STATUS_CREATE:
-		status = "create";
+		status = _("create");
 		break;
 	case PUSH_STATUS_DELETE:
-		status = "delete";
-		src = "(none)";
+		status = _("delete");
+		src = _("(none)");
 		break;
 	case PUSH_STATUS_UPTODATE:
-		status = "up to date";
+		status = _("up to date");
 		break;
 	case PUSH_STATUS_FASTFORWARD:
-		status = "fast-forwardable";
+		status = _("fast-forwardable");
 		break;
 	case PUSH_STATUS_OUTOFDATE:
-		status = "local out of date";
+		status = _("local out of date");
 		break;
 	case PUSH_STATUS_NOTQUERIED:
 		break;
 	}
-	if (status)
-		printf("    %-*s %s to %-*s (%s)\n", show_info->width, src,
-			push_info->forced ? "forces" : "pushes",
-			show_info->width2, push_info->dest, status);
-	else
-		printf("    %-*s %s to %s\n", show_info->width, src,
-			push_info->forced ? "forces" : "pushes",
-			push_info->dest);
+	if (status) {
+		if (push_info->forced)
+			printf_ln(_("    %-*s forces to %-*s (%s)"), show_info->width, src,
+			       show_info->width2, push_info->dest, status);
+		else
+			printf_ln(_("    %-*s pushes to %-*s (%s)"), show_info->width, src,
+			       show_info->width2, push_info->dest, status);
+	} else {
+		if (push_info->forced)
+			printf_ln(_("    %-*s forces to %s"), show_info->width, src,
+			       push_info->dest);
+		else
+			printf_ln(_("    %-*s pushes to %s"), show_info->width, src,
+			       push_info->dest);
+	}
 	return 0;
 }
 
@@ -1107,9 +1114,9 @@ static int show(int argc, const char **argv)
 
 		get_remote_ref_states(*argv, &states, query_flag);
 
-		printf("* remote %s\n", *argv);
-		printf("  Fetch URL: %s\n", states.remote->url_nr > 0 ?
-			states.remote->url[0] : "(no URL)");
+		printf_ln(_("* remote %s"), *argv);
+		printf_ln(_("  Fetch URL: %s"), states.remote->url_nr > 0 ?
+		       states.remote->url[0] : _("(no URL)"));
 		if (states.remote->pushurl_nr) {
 			url = states.remote->pushurl;
 			url_nr = states.remote->pushurl_nr;
@@ -1118,18 +1125,18 @@ static int show(int argc, const char **argv)
 			url_nr = states.remote->url_nr;
 		}
 		for (i = 0; i < url_nr; i++)
-			printf("  Push  URL: %s\n", url[i]);
+			printf_ln(_("  Push  URL: %s"), url[i]);
 		if (!i)
-			printf("  Push  URL: %s\n", "(no URL)");
+			printf_ln(_("  Push  URL: %s"), "(no URL)");
 		if (no_query)
-			printf("  HEAD branch: (not queried)\n");
+			printf_ln(_("  HEAD branch: %s"), "(not queried)");
 		else if (!states.heads.nr)
-			printf("  HEAD branch: (unknown)\n");
+			printf_ln(_("  HEAD branch: %s"), "(unknown)");
 		else if (states.heads.nr == 1)
-			printf("  HEAD branch: %s\n", states.heads.items[0].string);
+			printf_ln(_("  HEAD branch: %s"), states.heads.items[0].string);
 		else {
-			printf("  HEAD branch (remote HEAD is ambiguous,"
-			       " may be one of the following):\n");
+			printf(_("  HEAD branch (remote HEAD is ambiguous,"
+				 " may be one of the following):\n"));
 			for (i = 0; i < states.heads.nr; i++)
 				printf("    %s\n", states.heads.items[i].string);
 		}
@@ -1140,9 +1147,10 @@ static int show(int argc, const char **argv)
 		for_each_string_list(&states.tracked, add_remote_to_show_info, &info);
 		for_each_string_list(&states.stale, add_remote_to_show_info, &info);
 		if (info.list->nr)
-			printf("  Remote branch%s:%s\n",
-			       info.list->nr > 1 ? "es" : "",
-				no_query ? " (status not queried)" : "");
+			printf_ln(Q_("  Remote branch:%s",
+				     "  Remote branches:%s",
+				     info.list->nr),
+				  no_query ? _(" (status not queried)") : "");
 		for_each_string_list(info.list, show_remote_info_item, &info);
 		string_list_clear(info.list, 0);
 
@@ -1151,23 +1159,25 @@ static int show(int argc, const char **argv)
 		info.any_rebase = 0;
 		for_each_string_list(&branch_list, add_local_to_show_info, &info);
 		if (info.list->nr)
-			printf("  Local branch%s configured for 'git pull':\n",
-			       info.list->nr > 1 ? "es" : "");
+			printf_ln(Q_("  Local branch configured for 'git pull':",
+				     "  Local branches configured for 'git pull':",
+				     info.list->nr));
 		for_each_string_list(info.list, show_local_info_item, &info);
 		string_list_clear(info.list, 0);
 
 		/* git push info */
 		if (states.remote->mirror)
-			printf("  Local refs will be mirrored by 'git push'\n");
+			printf_ln(_("  Local refs will be mirrored by 'git push'"));
 
 		info.width = info.width2 = 0;
 		for_each_string_list(&states.push, add_push_to_show_info, &info);
 		qsort(info.list->items, info.list->nr,
 			sizeof(*info.list->items), cmp_string_with_push);
 		if (info.list->nr)
-			printf("  Local ref%s configured for 'git push'%s:\n",
-				info.list->nr > 1 ? "s" : "",
-				no_query ? " (status not queried)" : "");
+			printf_ln(Q_("  Local ref configured for 'git push'%s:",
+				     "  Local refs configured for 'git push'%s:",
+				     info.list->nr),
+				  no_query ? _(" (status not queried)") : "");
 		for_each_string_list(info.list, show_push_info_item, &info);
 		string_list_clear(info.list, 0);
 
@@ -1202,10 +1212,10 @@ static int set_head(int argc, const char **argv)
 		memset(&states, 0, sizeof(states));
 		get_remote_ref_states(argv[0], &states, GET_HEAD_NAMES);
 		if (!states.heads.nr)
-			result |= error("Cannot determine remote HEAD");
+			result |= error(_("Cannot determine remote HEAD"));
 		else if (states.heads.nr > 1) {
-			result |= error("Multiple remote HEAD branches. "
-					"Please choose one explicitly with:");
+			result |= error(_("Multiple remote HEAD branches. "
+					  "Please choose one explicitly with:"));
 			for (i = 0; i < states.heads.nr; i++)
 				fprintf(stderr, "  git remote set-head %s %s\n",
 					argv[0], states.heads.items[i].string);
@@ -1214,7 +1224,7 @@ static int set_head(int argc, const char **argv)
 		free_remote_ref_states(&states);
 	} else if (opt_d && !opt_a && argc == 1) {
 		if (delete_ref(buf.buf, NULL, REF_NODEREF))
-			result |= error("Could not delete %s", buf.buf);
+			result |= error(_("Could not delete %s"), buf.buf);
 	} else
 		usage_with_options(builtin_remote_sethead_usage, options);
 
@@ -1222,9 +1232,9 @@ static int set_head(int argc, const char **argv)
 		strbuf_addf(&buf2, "refs/remotes/%s/%s", argv[0], head_name);
 		/* make sure it's valid */
 		if (!ref_exists(buf2.buf))
-			result |= error("Not a valid ref: %s", buf2.buf);
+			result |= error(_("Not a valid ref: %s"), buf2.buf);
 		else if (create_symref(buf.buf, buf2.buf, "remote set-head"))
-			result |= error("Could not setup %s", buf.buf);
+			result |= error(_("Could not setup %s"), buf.buf);
 		if (opt_a)
 			printf("%s/HEAD set to %s\n", argv[0], head_name);
 		free(head_name);
@@ -1260,18 +1270,18 @@ static int prune_remote(const char *remote, int dry_run)
 	int result = 0, i;
 	struct ref_states states;
 	const char *dangling_msg = dry_run
-		? " %s will become dangling!"
-		: " %s has become dangling!";
+		? _(" %s will become dangling!")
+		: _(" %s has become dangling!");
 
 	memset(&states, 0, sizeof(states));
 	get_remote_ref_states(remote, &states, GET_REF_STATES);
 
 	if (states.stale.nr) {
-		printf("Pruning %s\n", remote);
-		printf("URL: %s\n",
+		printf_ln(_("Pruning %s"), remote);
+		printf_ln(_("URL: %s"),
 		       states.remote->url_nr
 		       ? states.remote->url[0]
-		       : "(no URL)");
+		       : _("(no URL)"));
 	}
 
 	for (i = 0; i < states.stale.nr; i++) {
@@ -1280,8 +1290,12 @@ static int prune_remote(const char *remote, int dry_run)
 		if (!dry_run)
 			result |= delete_ref(refname, NULL, 0);
 
-		printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
-		       abbrev_ref(refname, "refs/remotes/"));
+		if (dry_run)
+			printf_ln(_(" * [would prune] %s"),
+			       abbrev_ref(refname, "refs/remotes/"));
+		else
+			printf_ln(_(" * [pruned] %s"),
+			       abbrev_ref(refname, "refs/remotes/"));
 		warn_dangling_symref(stdout, dangling_msg, refname);
 	}
 
@@ -1369,7 +1383,7 @@ static int set_remote_branches(const char *remotename, const char **branches,
 	strbuf_addf(&key, "remote.%s.fetch", remotename);
 
 	if (!remote_is_configured(remotename))
-		die("No such remote '%s'", remotename);
+		die(_("No such remote '%s'"), remotename);
 	remote = remote_get(remotename);
 
 	if (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {
@@ -1396,7 +1410,7 @@ static int set_branches(int argc, const char **argv)
 	argc = parse_options(argc, argv, NULL, options,
 			     builtin_remote_setbranches_usage, 0);
 	if (argc == 0) {
-		error("no remote specified");
+		error(_("no remote specified"));
 		usage_with_options(builtin_remote_setbranches_usage, options);
 	}
 	argv[argc] = NULL;
@@ -1429,7 +1443,7 @@ static int set_url(int argc, const char **argv)
 			     PARSE_OPT_KEEP_ARGV0);
 
 	if (add_mode && delete_mode)
-		die("--add --delete doesn't make sense");
+		die(_("--add --delete doesn't make sense"));
 
 	if (argc < 3 || argc > 4 || ((add_mode || delete_mode) && argc != 3))
 		usage_with_options(builtin_remote_seturl_usage, options);
@@ -1443,7 +1457,7 @@ static int set_url(int argc, const char **argv)
 		oldurl = newurl;
 
 	if (!remote_is_configured(remotename))
-		die("No such remote '%s'", remotename);
+		die(_("No such remote '%s'"), remotename);
 	remote = remote_get(remotename);
 
 	if (push_mode) {
@@ -1469,7 +1483,7 @@ static int set_url(int argc, const char **argv)
 
 	/* Old URL specified. Demand that one matches. */
 	if (regcomp(&old_regex, oldurl, REG_EXTENDED))
-		die("Invalid old URL pattern: %s", oldurl);
+		die(_("Invalid old URL pattern: %s"), oldurl);
 
 	for (i = 0; i < urlset_nr; i++)
 		if (!regexec(&old_regex, urlset[i], 0, NULL, 0))
@@ -1477,9 +1491,9 @@ static int set_url(int argc, const char **argv)
 		else
 			negative_matches++;
 	if (!delete_mode && !matches)
-		die("No such URL found: %s", oldurl);
+		die(_("No such URL found: %s"), oldurl);
 	if (delete_mode && !negative_matches && !push_mode)
-		die("Will not delete all non-push URLs");
+		die(_("Will not delete all non-push URLs"));
 
 	regfree(&old_regex);
 
@@ -1551,7 +1565,7 @@ static int show_all(void)
 int cmd_remote(int argc, const char **argv, const char *prefix)
 {
 	struct option options[] = {
-		OPT__VERBOSE(&verbose, "be verbose; must be placed before a subcommand"),
+		OPT__VERBOSE(&verbose, N_("be verbose; must be placed before a subcommand")),
 		OPT_END()
 	};
 	int result;
@@ -1580,7 +1594,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix)
 	else if (!strcmp(argv[0], "update"))
 		result = update(argc, argv);
 	else {
-		error("Unknown subcommand: %s", argv[0]);
+		error(_("Unknown subcommand: %s"), argv[0]);
 		usage_with_options(builtin_remote_usage, options);
 	}
 
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 08/11] i18n: apply: mark strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (6 preceding siblings ...)
  2012-04-16 12:49 ` [PATCH i18n 07/11] i18n: remote: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:50 ` Nguyễn Thái Ngọc Duy
  2012-04-16 12:50 ` [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence Nguyễn Thái Ngọc Duy
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:50 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 builtin/apply.c |  226 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 114 insertions(+), 112 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 389898f..6e9a02e 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -50,7 +50,7 @@ static const char *fake_ancestor;
 static int line_termination = '\n';
 static unsigned int p_context = UINT_MAX;
 static const char * const apply_usage[] = {
-	"git apply [options] [<patch>...]",
+	N_("git apply [options] [<patch>...]"),
 	NULL
 };
 
@@ -103,7 +103,7 @@ static void parse_whitespace_option(const char *option)
 		ws_error_action = correct_ws_error;
 		return;
 	}
-	die("unrecognized whitespace option '%s'", option);
+	die(_("unrecognized whitespace option '%s'"), option);
 }
 
 static void parse_ignorewhitespace_option(const char *option)
@@ -118,7 +118,7 @@ static void parse_ignorewhitespace_option(const char *option)
 		ws_ignore_action = ignore_ws_change;
 		return;
 	}
-	die("unrecognized whitespace ignore option '%s'", option);
+	die(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
 static void set_default_whitespace_mode(const char *whitespace_option)
@@ -770,7 +770,7 @@ static int has_epoch_timestamp(const char *nameline)
 	if (!stamp) {
 		stamp = xmalloc(sizeof(*stamp));
 		if (regcomp(stamp, stamp_regexp, REG_EXTENDED)) {
-			warning("Cannot prepare timestamp regexp %s",
+			warning(_("Cannot prepare timestamp regexp %s"),
 				stamp_regexp);
 			return 0;
 		}
@@ -779,7 +779,7 @@ static int has_epoch_timestamp(const char *nameline)
 	status = regexec(stamp, timestamp, ARRAY_SIZE(m), m, 0);
 	if (status) {
 		if (status != REG_NOMATCH)
-			warning("regexec returned %d for input: %s",
+			warning(_("regexec returned %d for input: %s"),
 				status, timestamp);
 		return 0;
 	}
@@ -857,7 +857,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
 		}
 	}
 	if (!name)
-		die("unable to find filename in patch at line %d", linenr);
+		die(_("unable to find filename in patch at line %d"), linenr);
 }
 
 static int gitdiff_hdrend(const char *line, struct patch *patch)
@@ -886,17 +886,17 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
 		name = orig_name;
 		len = strlen(name);
 		if (isnull)
-			die("git apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
+			die(_("git apply: bad git-diff - expected /dev/null, got %s on line %d"), name, linenr);
 		another = find_name(line, NULL, p_value, TERM_TAB);
 		if (!another || memcmp(another, name, len + 1))
-			die("git apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
+			die(_("git apply: bad git-diff - inconsistent %s filename on line %d"), oldnew, linenr);
 		free(another);
 		return orig_name;
 	}
 	else {
 		/* expect "/dev/null" */
 		if (memcmp("/dev/null", line, 9) || line[9] != '\n')
-			die("git apply: bad git-diff - expected /dev/null on line %d", linenr);
+			die(_("git apply: bad git-diff - expected /dev/null on line %d"), linenr);
 		return NULL;
 	}
 }
@@ -1327,7 +1327,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)
 			break;
 		}
 		if (ret) {
-			warning("recount: unexpected line: %.*s",
+			warning(_("recount: unexpected line: %.*s"),
 				(int)linelen(line, size), line);
 			return;
 		}
@@ -1384,7 +1384,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
 			struct fragment dummy;
 			if (parse_fragment_header(line, len, &dummy) < 0)
 				continue;
-			die("patch fragment without header at line %d: %.*s",
+			die(_("patch fragment without header at line %d: %.*s"),
 			    linenr, (int)len-1, line);
 		}
 
@@ -1556,9 +1556,9 @@ static int parse_fragment(char *line, unsigned long size,
 	patch->lines_deleted += deleted;
 
 	if (0 < patch->is_new && oldlines)
-		return error("new file depends on old contents");
+		return error(_("new file depends on old contents"));
 	if (0 < patch->is_delete && newlines)
-		return error("deleted file still has contents");
+		return error(_("deleted file still has contents"));
 	return offset;
 }
 
@@ -1576,7 +1576,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc
 		fragment->linenr = linenr;
 		len = parse_fragment(line, size, patch, fragment);
 		if (len <= 0)
-			die("corrupt patch at line %d", linenr);
+			die(_("corrupt patch at line %d"), linenr);
 		fragment->patch = line;
 		fragment->size = len;
 		oldlines += fragment->oldlines;
@@ -1612,12 +1612,14 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc
 		patch->is_delete = 0;
 
 	if (0 < patch->is_new && oldlines)
-		die("new file %s depends on old contents", patch->new_name);
+		die(_("new file %s depends on old contents"), patch->new_name);
 	if (0 < patch->is_delete && newlines)
-		die("deleted file %s still has contents", patch->old_name);
+		die(_("deleted file %s still has contents"), patch->old_name);
 	if (!patch->is_delete && !newlines && context)
-		fprintf(stderr, "** warning: file %s becomes empty but "
-			"is not deleted\n", patch->new_name);
+		fprintf_ln(stderr,
+			   _("** warning: "
+			     "file %s becomes empty but is not deleted"),
+			   patch->new_name);
 
 	return offset;
 }
@@ -1755,7 +1757,7 @@ static struct fragment *parse_binary_hunk(char **buf_p,
  corrupt:
 	free(data);
 	*status_p = -1;
-	error("corrupt binary patch at line %d: %.*s",
+	error(_("corrupt binary patch at line %d: %.*s"),
 	      linenr-1, llen-1, buffer);
 	return NULL;
 }
@@ -1784,7 +1786,7 @@ static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
 	forward = parse_binary_hunk(&buffer, &size, &status, &used);
 	if (!forward && !status)
 		/* there has to be one hunk (forward hunk) */
-		return error("unrecognized binary patch at line %d", linenr-1);
+		return error(_("unrecognized binary patch at line %d"), linenr-1);
 	if (status)
 		/* otherwise we already gave an error message */
 		return status;
@@ -1863,7 +1865,7 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)
 		 */
 		if ((apply || check) &&
 		    (!patch->is_binary && !metadata_changes(patch)))
-			die("patch with only garbage at line %d", linenr);
+			die(_("patch with only garbage at line %d"), linenr);
 	}
 
 	return offset + hdrsize + patchsize;
@@ -1953,11 +1955,11 @@ static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)
 	switch (st->st_mode & S_IFMT) {
 	case S_IFLNK:
 		if (strbuf_readlink(buf, path, st->st_size) < 0)
-			return error("unable to read symlink %s", path);
+			return error(_("unable to read symlink %s"), path);
 		return 0;
 	case S_IFREG:
 		if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
-			return error("unable to open or read %s", path);
+			return error(_("unable to open or read %s"), path);
 		convert_to_git(path, buf->buf, buf->len, buf, 0);
 		return 0;
 	default:
@@ -2028,7 +2030,7 @@ static void update_pre_post_images(struct image *preimage,
 			ctx++;
 		}
 		if (preimage->nr <= ctx)
-			die("oops");
+			die(_("oops"));
 
 		/* and copy it in, while fixing the line length */
 		len = preimage->line[ctx].len;
@@ -2540,7 +2542,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
 			break;
 		default:
 			if (apply_verbosely)
-				error("invalid start of line: '%c'", first);
+				error(_("invalid start of line: '%c'"), first);
 			return -1;
 		}
 		if (added_blank_line) {
@@ -2657,9 +2659,9 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
 			int offset = applied_pos - pos;
 			if (apply_in_reverse)
 				offset = 0 - offset;
-			fprintf(stderr,
-				"Hunk #%d succeeded at %d (offset %d lines).\n",
-				nth_fragment, applied_pos + 1, offset);
+			fprintf_ln(stderr,
+				   _("Hunk #%d succeeded at %d (offset %d lines)."),
+				   nth_fragment, applied_pos + 1, offset);
 		}
 
 		/*
@@ -2668,13 +2670,13 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
 		 */
 		if ((leading != frag->leading) ||
 		    (trailing != frag->trailing))
-			fprintf(stderr, "Context reduced to (%ld/%ld)"
-				" to apply fragment at %d\n",
-				leading, trailing, applied_pos+1);
+			fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
+					     " to apply fragment at %d"),
+				   leading, trailing, applied_pos+1);
 		update_image(img, applied_pos, &preimage, &postimage);
 	} else {
 		if (apply_verbosely)
-			error("while searching for:\n%.*s",
+			error(_("while searching for:\n%.*s"),
 			      (int)(old - oldlines), oldlines);
 	}
 
@@ -2693,7 +2695,7 @@ static int apply_binary_fragment(struct image *img, struct patch *patch)
 	void *dst;
 
 	if (!fragment)
-		return error("missing binary patch data for '%s'",
+		return error(_("missing binary patch data for '%s'"),
 			     patch->new_name ?
 			     patch->new_name :
 			     patch->old_name);
@@ -2790,13 +2792,13 @@ static int apply_binary(struct image *img, struct patch *patch)
 		 * in the patch->fragments->{patch,size}.
 		 */
 		if (apply_binary_fragment(img, patch))
-			return error("binary patch does not apply to '%s'",
+			return error(_("binary patch does not apply to '%s'"),
 				     name);
 
 		/* verify that the result matches */
 		hash_sha1_file(img->buf, img->len, blob_type, sha1);
 		if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
-			return error("binary patch to '%s' creates incorrect result (expecting %s, got %s)",
+			return error(_("binary patch to '%s' creates incorrect result (expecting %s, got %s)"),
 				name, patch->new_sha1_prefix, sha1_to_hex(sha1));
 	}
 
@@ -2817,7 +2819,7 @@ static int apply_fragments(struct image *img, struct patch *patch)
 	while (frag) {
 		nth++;
 		if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule, nth)) {
-			error("patch failed: %s:%ld", name, frag->oldpos);
+			error(_("patch failed: %s:%ld"), name, frag->oldpos);
 			if (!apply_with_reject)
 				return -1;
 			frag->rejected = 1;
@@ -2932,14 +2934,14 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
 	if (!(patch->is_copy || patch->is_rename) &&
 	    (tpatch = in_fn_table(patch->old_name)) != NULL && !to_be_deleted(tpatch)) {
 		if (was_deleted(tpatch)) {
-			return error("patch %s has been renamed/deleted",
+			return error(_("patch %s has been renamed/deleted"),
 				patch->old_name);
 		}
 		/* We have a patched copy in memory use that */
 		strbuf_add(&buf, tpatch->result, tpatch->resultsize);
 	} else if (cached) {
 		if (read_file_or_gitlink(ce, &buf))
-			return error("read of %s failed", patch->old_name);
+			return error(_("read of %s failed"), patch->old_name);
 	} else if (patch->old_name) {
 		if (S_ISGITLINK(patch->old_mode)) {
 			if (ce) {
@@ -2953,7 +2955,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
 			}
 		} else {
 			if (read_old_data(st, patch->old_name, &buf))
-				return error("read of %s failed", patch->old_name);
+				return error(_("read of %s failed"), patch->old_name);
 		}
 	}
 
@@ -2968,7 +2970,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
 	free(image.line_allocated);
 
 	if (0 < patch->is_delete && patch->resultsize)
-		return error("removal patch leaves file contents");
+		return error(_("removal patch leaves file contents"));
 
 	return 0;
 }
@@ -2989,7 +2991,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
 		if (has_symlink_leading_path(new_name, strlen(new_name)))
 			return 0;
 
-		return error("%s: already exists in working directory", new_name);
+		return error(_("%s: already exists in working directory"), new_name);
 	}
 	else if ((errno != ENOENT) && (errno != ENOTDIR))
 		return error("%s: %s", new_name, strerror(errno));
@@ -3027,12 +3029,12 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 	if (!(patch->is_copy || patch->is_rename) &&
 	    (tpatch = in_fn_table(old_name)) != NULL && !to_be_deleted(tpatch)) {
 		if (was_deleted(tpatch))
-			return error("%s: has been deleted/renamed", old_name);
+			return error(_("%s: has been deleted/renamed"), old_name);
 		st_mode = tpatch->new_mode;
 	} else if (!cached) {
 		stat_ret = lstat(old_name, st);
 		if (stat_ret && errno != ENOENT)
-			return error("%s: %s", old_name, strerror(errno));
+			return error(_("%s: %s"), old_name, strerror(errno));
 	}
 
 	if (to_be_deleted(tpatch))
@@ -3043,7 +3045,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 		if (pos < 0) {
 			if (patch->is_new < 0)
 				goto is_new;
-			return error("%s: does not exist in index", old_name);
+			return error(_("%s: does not exist in index"), old_name);
 		}
 		*ce = active_cache[pos];
 		if (stat_ret < 0) {
@@ -3057,13 +3059,13 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 				return -1;
 		}
 		if (!cached && verify_index_match(*ce, st))
-			return error("%s: does not match index", old_name);
+			return error(_("%s: does not match index"), old_name);
 		if (cached)
 			st_mode = (*ce)->ce_mode;
 	} else if (stat_ret < 0) {
 		if (patch->is_new < 0)
 			goto is_new;
-		return error("%s: %s", old_name, strerror(errno));
+		return error(_("%s: %s"), old_name, strerror(errno));
 	}
 
 	if (!cached && !tpatch)
@@ -3074,9 +3076,9 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 	if (!patch->old_mode)
 		patch->old_mode = st_mode;
 	if ((st_mode ^ patch->old_mode) & S_IFMT)
-		return error("%s: wrong type", old_name);
+		return error(_("%s: wrong type"), old_name);
 	if (st_mode != patch->old_mode)
-		warning("%s has type %o, expected %o",
+		warning(_("%s has type %o, expected %o"),
 			old_name, st_mode, patch->old_mode);
 	if (!patch->new_mode && !patch->is_delete)
 		patch->new_mode = st_mode;
@@ -3126,7 +3128,7 @@ static int check_patch(struct patch *patch)
 		if (check_index &&
 		    cache_name_pos(new_name, strlen(new_name)) >= 0 &&
 		    !ok_if_exists)
-			return error("%s: already exists in index", new_name);
+			return error(_("%s: already exists in index"), new_name);
 		if (!cached) {
 			int err = check_to_create_blob(new_name, ok_if_exists);
 			if (err)
@@ -3145,13 +3147,13 @@ static int check_patch(struct patch *patch)
 		if (!patch->new_mode)
 			patch->new_mode = patch->old_mode;
 		if ((patch->old_mode ^ patch->new_mode) & S_IFMT)
-			return error("new mode (%o) of %s does not match old mode (%o)%s%s",
+			return error(_("new mode (%o) of %s does not match old mode (%o)%s%s"),
 				patch->new_mode, new_name, patch->old_mode,
 				same ? "" : " of ", same ? "" : old_name);
 	}
 
 	if (apply_data(patch, &st, ce) < 0)
-		return error("%s: patch does not apply", name);
+		return error(_("%s: patch does not apply"), name);
 	patch->rejected = 0;
 	return 0;
 }
@@ -3219,7 +3221,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
 
 		ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
 		if (!ce)
-			die("make_cache_entry failed for path '%s'", name);
+			die(_("make_cache_entry failed for path '%s'"), name);
 		if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
 			die ("Could not add %s to temporary index", name);
 	}
@@ -3362,7 +3364,7 @@ static void remove_file(struct patch *patch, int rmdir_empty)
 {
 	if (update_index) {
 		if (remove_file_from_cache(patch->old_name) < 0)
-			die("unable to remove %s from index", patch->old_name);
+			die(_("unable to remove %s from index"), patch->old_name);
 	}
 	if (!cached) {
 		if (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {
@@ -3389,19 +3391,19 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
 		const char *s = buf;
 
 		if (get_sha1_hex(s + strlen("Subproject commit "), ce->sha1))
-			die("corrupt patch for subproject %s", path);
+			die(_("corrupt patch for subproject %s"), path);
 	} else {
 		if (!cached) {
 			if (lstat(path, &st) < 0)
-				die_errno("unable to stat newly created file '%s'",
+				die_errno(_("unable to stat newly created file '%s'"),
 					  path);
 			fill_stat_cache_info(ce, &st);
 		}
 		if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
-			die("unable to create backing store for newly created file %s", path);
+			die(_("unable to create backing store for newly created file %s"), path);
 	}
 	if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
-		die("unable to add cache entry for %s", path);
+		die(_("unable to add cache entry for %s"), path);
 }
 
 static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)
@@ -3434,7 +3436,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,
 	strbuf_release(&nbuf);
 
 	if (close(fd) < 0)
-		die_errno("closing file '%s'", path);
+		die_errno(_("closing file '%s'"), path);
 	return 0;
 }
 
@@ -3483,7 +3485,7 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
 			++nr;
 		}
 	}
-	die_errno("unable to write file '%s' mode %o", path, mode);
+	die_errno(_("unable to write file '%s' mode %o"), path, mode);
 }
 
 static void create_file(struct patch *patch)
@@ -3546,7 +3548,7 @@ static int write_out_one_reject(struct patch *patch)
 	 * contents are marked "rejected" at the patch level.
 	 */
 	if (!patch->new_name)
-		die("internal error");
+		die(_("internal error"));
 
 	/* Say this even without --verbose */
 	say_patch_name(stderr, "Applying patch ", patch, " with");
@@ -3555,7 +3557,7 @@ static int write_out_one_reject(struct patch *patch)
 	cnt = strlen(patch->new_name);
 	if (ARRAY_SIZE(namebuf) <= cnt + 5) {
 		cnt = ARRAY_SIZE(namebuf) - 5;
-		warning("truncating .rej filename to %.*s.rej",
+		warning(_("truncating .rej filename to %.*s.rej"),
 			cnt - 1, patch->new_name);
 	}
 	memcpy(namebuf, patch->new_name, cnt);
@@ -3563,7 +3565,7 @@ static int write_out_one_reject(struct patch *patch)
 
 	rej = fopen(namebuf, "w");
 	if (!rej)
-		return error("cannot open %s: %s", namebuf, strerror(errno));
+		return error(_("cannot open %s: %s"), namebuf, strerror(errno));
 
 	/* Normal git tools never deal with .rej, so do not pretend
 	 * this is a git patch by saying --git nor give extended
@@ -3576,10 +3578,10 @@ static int write_out_one_reject(struct patch *patch)
 	     frag;
 	     cnt++, frag = frag->next) {
 		if (!frag->rejected) {
-			fprintf(stderr, "Hunk #%d applied cleanly.\n", cnt);
+			fprintf_ln(stderr, _("Hunk #%d applied cleanly."), cnt);
 			continue;
 		}
-		fprintf(stderr, "Rejected hunk #%d.\n", cnt);
+		fprintf_ln(stderr, _("Rejected hunk #%d."), cnt);
 		fprintf(rej, "%.*s", frag->size, frag->patch);
 		if (frag->patch[frag->size-1] != '\n')
 			fputc('\n', rej);
@@ -3720,7 +3722,7 @@ static int apply_patch(int fd, const char *filename, int options)
 	}
 
 	if (!list && !skipped_patch)
-		die("unrecognized input");
+		die(_("unrecognized input"));
 
 	if (whitespace_error && (ws_error_action == die_on_ws_error))
 		apply = 0;
@@ -3731,7 +3733,7 @@ static int apply_patch(int fd, const char *filename, int options)
 
 	if (check_index) {
 		if (read_cache() < 0)
-			die("unable to read index file");
+			die(_("unable to read index file"));
 	}
 
 	if ((check || apply) &&
@@ -3844,66 +3846,66 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
 	const char *whitespace_option = NULL;
 
 	struct option builtin_apply_options[] = {
-		{ OPTION_CALLBACK, 0, "exclude", NULL, "path",
-			"don't apply changes matching the given path",
+		{ OPTION_CALLBACK, 0, "exclude", NULL, N_("path"),
+			N_("don't apply changes matching the given path"),
 			0, option_parse_exclude },
-		{ OPTION_CALLBACK, 0, "include", NULL, "path",
-			"apply changes matching the given path",
+		{ OPTION_CALLBACK, 0, "include", NULL, N_("path"),
+			N_("apply changes matching the given path"),
 			0, option_parse_include },
-		{ OPTION_CALLBACK, 'p', NULL, NULL, "num",
-			"remove <num> leading slashes from traditional diff paths",
+		{ OPTION_CALLBACK, 'p', NULL, NULL, N_("num"),
+			N_("remove <num> leading slashes from traditional diff paths"),
 			0, option_parse_p },
 		OPT_BOOLEAN(0, "no-add", &no_add,
-			"ignore additions made by the patch"),
+			N_("ignore additions made by the patch")),
 		OPT_BOOLEAN(0, "stat", &diffstat,
-			"instead of applying the patch, output diffstat for the input"),
+			N_("instead of applying the patch, output diffstat for the input")),
 		OPT_NOOP_NOARG(0, "allow-binary-replacement"),
 		OPT_NOOP_NOARG(0, "binary"),
 		OPT_BOOLEAN(0, "numstat", &numstat,
-			"shows number of added and deleted lines in decimal notation"),
+			N_("shows number of added and deleted lines in decimal notation")),
 		OPT_BOOLEAN(0, "summary", &summary,
-			"instead of applying the patch, output a summary for the input"),
+			N_("instead of applying the patch, output a summary for the input")),
 		OPT_BOOLEAN(0, "check", &check,
-			"instead of applying the patch, see if the patch is applicable"),
+			N_("instead of applying the patch, see if the patch is applicable")),
 		OPT_BOOLEAN(0, "index", &check_index,
-			"make sure the patch is applicable to the current index"),
+			N_("make sure the patch is applicable to the current index")),
 		OPT_BOOLEAN(0, "cached", &cached,
-			"apply a patch without touching the working tree"),
+			N_("apply a patch without touching the working tree")),
 		OPT_BOOLEAN(0, "apply", &force_apply,
-			"also apply the patch (use with --stat/--summary/--check)"),
+			N_("also apply the patch (use with --stat/--summary/--check)")),
 		OPT_FILENAME(0, "build-fake-ancestor", &fake_ancestor,
-			"build a temporary index based on embedded index information"),
+			N_("build a temporary index based on embedded index information")),
 		{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,
-			"paths are separated with NUL character",
+			N_("paths are separated with NUL character"),
 			PARSE_OPT_NOARG, option_parse_z },
 		OPT_INTEGER('C', NULL, &p_context,
-				"ensure at least <n> lines of context match"),
-		{ OPTION_CALLBACK, 0, "whitespace", &whitespace_option, "action",
-			"detect new or modified lines that have whitespace errors",
+				N_("ensure at least <n> lines of context match")),
+		{ OPTION_CALLBACK, 0, "whitespace", &whitespace_option, N_("action"),
+			N_("detect new or modified lines that have whitespace errors"),
 			0, option_parse_whitespace },
 		{ OPTION_CALLBACK, 0, "ignore-space-change", NULL, NULL,
-			"ignore changes in whitespace when finding context",
+			N_("ignore changes in whitespace when finding context"),
 			PARSE_OPT_NOARG, option_parse_space_change },
 		{ OPTION_CALLBACK, 0, "ignore-whitespace", NULL, NULL,
-			"ignore changes in whitespace when finding context",
+			N_("ignore changes in whitespace when finding context"),
 			PARSE_OPT_NOARG, option_parse_space_change },
 		OPT_BOOLEAN('R', "reverse", &apply_in_reverse,
-			"apply the patch in reverse"),
+			N_("apply the patch in reverse")),
 		OPT_BOOLEAN(0, "unidiff-zero", &unidiff_zero,
-			"don't expect at least one line of context"),
+			N_("don't expect at least one line of context")),
 		OPT_BOOLEAN(0, "reject", &apply_with_reject,
-			"leave the rejected hunks in corresponding *.rej files"),
+			N_("leave the rejected hunks in corresponding *.rej files")),
 		OPT_BOOLEAN(0, "allow-overlap", &allow_overlap,
-			"allow overlapping hunks"),
-		OPT__VERBOSE(&apply_verbosely, "be verbose"),
+			N_("allow overlapping hunks")),
+		OPT__VERBOSE(&apply_verbosely, N_("be verbose")),
 		OPT_BIT(0, "inaccurate-eof", &options,
-			"tolerate incorrectly detected missing new-line at the end of file",
+			N_("tolerate incorrectly detected missing new-line at the end of file"),
 			INACCURATE_EOF),
 		OPT_BIT(0, "recount", &options,
-			"do not trust the line counts in the hunk headers",
+			N_("do not trust the line counts in the hunk headers"),
 			RECOUNT),
-		{ OPTION_CALLBACK, 0, "directory", NULL, "root",
-			"prepend <root> to all filenames",
+		{ OPTION_CALLBACK, 0, "directory", NULL, N_("root"),
+			N_("prepend <root> to all filenames"),
 			0, option_parse_directory },
 		OPT_END()
 	};
@@ -3924,10 +3926,10 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
 	if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
 		apply = 0;
 	if (check_index && is_not_gitdir)
-		die("--index outside a repository");
+		die(_("--index outside a repository"));
 	if (cached) {
 		if (is_not_gitdir)
-			die("--cached outside a repository");
+			die(_("--cached outside a repository"));
 		check_index = 1;
 	}
 	for (i = 0; i < argc; i++) {
@@ -3943,7 +3945,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
 
 		fd = open(arg, O_RDONLY);
 		if (fd < 0)
-			die_errno("can't open patch '%s'", arg);
+			die_errno(_("can't open patch '%s'"), arg);
 		read_stdin = 0;
 		set_default_whitespace_mode(whitespace_option);
 		errs |= apply_patch(fd, arg, options);
@@ -3957,32 +3959,32 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
 		    squelch_whitespace_errors < whitespace_error) {
 			int squelched =
 				whitespace_error - squelch_whitespace_errors;
-			warning("squelched %d "
-				"whitespace error%s",
-				squelched,
-				squelched == 1 ? "" : "s");
+			warning(Q_("squelched %d whitespace error",
+				   "squelched %d whitespace errors",
+				   squelched),
+				squelched);
 		}
 		if (ws_error_action == die_on_ws_error)
-			die("%d line%s add%s whitespace errors.",
-			    whitespace_error,
-			    whitespace_error == 1 ? "" : "s",
-			    whitespace_error == 1 ? "s" : "");
+			die(Q_("%d line adds whitespace errors.",
+			       "%d lines add whitespace errors.",
+			       whitespace_error),
+			    whitespace_error);
 		if (applied_after_fixing_ws && apply)
 			warning("%d line%s applied after"
 				" fixing whitespace errors.",
 				applied_after_fixing_ws,
 				applied_after_fixing_ws == 1 ? "" : "s");
 		else if (whitespace_error)
-			warning("%d line%s add%s whitespace errors.",
-				whitespace_error,
-				whitespace_error == 1 ? "" : "s",
-				whitespace_error == 1 ? "s" : "");
+			warning(Q_("%d line adds whitespace errors.",
+				   "%d lines add whitespace errors.",
+				   whitespace_error),
+				whitespace_error);
 	}
 
 	if (update_index) {
 		if (write_cache(newfd, active_cache, active_nr) ||
 		    commit_locked_index(&lock_file))
-			die("Unable to write new index file");
+			die(_("Unable to write new index file"));
 	}
 
 	return !!errs;
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (7 preceding siblings ...)
  2012-04-16 12:50 ` [PATCH i18n 08/11] i18n: apply: " Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:50 ` Nguyễn Thái Ngọc Duy
  2012-04-22 16:42   ` Zbigniew Jędrzejewski-Szmek
  2012-04-16 12:50 ` [PATCH i18n 10/11] i18n: index-pack: mark strings for translation Nguyễn Thái Ngọc Duy
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:50 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 builtin/apply.c |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 6e9a02e..87922cf 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -335,22 +335,25 @@ static void clear_image(struct image *image)
 	image->len = 0;
 }
 
-static void say_patch_name(FILE *output, const char *pre,
-			   struct patch *patch, const char *post)
+/* fmt must contain _one_ %s and no other substitution */
+static void say_patch_name(FILE *output, struct patch *patch, const char *fmt)
 {
-	fputs(pre, output);
+	struct strbuf sb = STRBUF_INIT;
+
 	if (patch->old_name && patch->new_name &&
 	    strcmp(patch->old_name, patch->new_name)) {
-		quote_c_style(patch->old_name, NULL, output, 0);
-		fputs(" => ", output);
-		quote_c_style(patch->new_name, NULL, output, 0);
+		quote_c_style(patch->old_name, &sb, NULL, 0);
+		strbuf_addstr(&sb, " => ");
+		quote_c_style(patch->new_name, &sb, NULL, 0);
 	} else {
 		const char *n = patch->new_name;
 		if (!n)
 			n = patch->old_name;
-		quote_c_style(n, NULL, output, 0);
+		quote_c_style(n, &sb, NULL, 0);
 	}
-	fputs(post, output);
+	fprintf(output, fmt, sb.buf);
+	fprintf(output, "\n");
+	strbuf_release(&sb);
 }
 
 #define CHUNKSIZE (8192)
@@ -3165,8 +3168,8 @@ static int check_patch_list(struct patch *patch)
 	prepare_fn_table(patch);
 	while (patch) {
 		if (apply_verbosely)
-			say_patch_name(stderr,
-				       "Checking patch ", patch, "...\n");
+			say_patch_name(stderr, patch,
+				       _("Checking patch %s..."));
 		err |= check_patch(patch);
 		patch = patch->next;
 	}
@@ -3530,6 +3533,7 @@ static int write_out_one_reject(struct patch *patch)
 	char namebuf[PATH_MAX];
 	struct fragment *frag;
 	int cnt = 0;
+	struct strbuf sb = STRBUF_INIT;
 
 	for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
 		if (!frag->rejected)
@@ -3539,8 +3543,8 @@ static int write_out_one_reject(struct patch *patch)
 
 	if (!cnt) {
 		if (apply_verbosely)
-			say_patch_name(stderr,
-				       "Applied patch ", patch, " cleanly.\n");
+			say_patch_name(stderr, patch,
+				       _("Applied patch %s cleanly."));
 		return 0;
 	}
 
@@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)
 		die(_("internal error"));
 
 	/* Say this even without --verbose */
-	say_patch_name(stderr, "Applying patch ", patch, " with");
-	fprintf(stderr, " %d rejects...\n", cnt);
+	strbuf_addf(&sb, _("Applying patch %%s with %d rejects..."), cnt);
+	say_patch_name(stderr, patch, sb.buf);
+	strbuf_release(&sb);
 
 	cnt = strlen(patch->new_name);
 	if (ARRAY_SIZE(namebuf) <= cnt + 5) {
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 10/11] i18n: index-pack: mark strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (8 preceding siblings ...)
  2012-04-16 12:50 ` [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:50 ` Nguyễn Thái Ngọc Duy
  2012-04-16 12:50 ` [PATCH i18n 11/11] i18n: bundle: " Nguyễn Thái Ngọc Duy
  2012-04-18 19:40 ` [PATCH i18n 00/11] Mark more " Jonathan Nieder
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:50 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 builtin/index-pack.c |  117 +++++++++++++++++++++++++------------------------
 1 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index dd1c5c9..1da8361 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -81,7 +81,7 @@ static int mark_link(struct object *obj, int type, void *data)
 		return -1;
 
 	if (type != OBJ_ANY && obj->type != type)
-		die("object type mismatch at %s", sha1_to_hex(obj->sha1));
+		die(_("object type mismatch at %s"), sha1_to_hex(obj->sha1));
 
 	obj->flags |= FLAG_LINK;
 	return 0;
@@ -101,7 +101,7 @@ static void check_object(struct object *obj)
 		unsigned long size;
 		int type = sha1_object_info(obj->sha1, &size);
 		if (type != obj->type || type <= 0)
-			die("object of unexpected type");
+			die(_("object of unexpected type"));
 		obj->flags |= FLAG_CHECKED;
 		return;
 	}
@@ -138,15 +138,15 @@ static void *fill(int min)
 	if (min <= input_len)
 		return input_buffer + input_offset;
 	if (min > sizeof(input_buffer))
-		die("cannot fill %d bytes", min);
+		die(_("cannot fill %d bytes"), min);
 	flush();
 	do {
 		ssize_t ret = xread(input_fd, input_buffer + input_len,
 				sizeof(input_buffer) - input_len);
 		if (ret <= 0) {
 			if (!ret)
-				die("early EOF");
-			die_errno("read error on input");
+				die(_("early EOF"));
+			die_errno(_("read error on input"));
 		}
 		input_len += ret;
 		if (from_stdin)
@@ -158,14 +158,14 @@ static void *fill(int min)
 static void use(int bytes)
 {
 	if (bytes > input_len)
-		die("used more bytes than were available");
+		die(_("used more bytes than were available"));
 	input_crc32 = crc32(input_crc32, input_buffer + input_offset, bytes);
 	input_len -= bytes;
 	input_offset += bytes;
 
 	/* make sure off_t is sufficiently large not to wrap */
 	if (signed_add_overflows(consumed_bytes, bytes))
-		die("pack too large for current definition of off_t");
+		die(_("pack too large for current definition of off_t"));
 	consumed_bytes += bytes;
 }
 
@@ -181,12 +181,12 @@ static const char *open_pack_file(const char *pack_name)
 		} else
 			output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
 		if (output_fd < 0)
-			die_errno("unable to create '%s'", pack_name);
+			die_errno(_("unable to create '%s'"), pack_name);
 		pack_fd = output_fd;
 	} else {
 		input_fd = open(pack_name, O_RDONLY);
 		if (input_fd < 0)
-			die_errno("cannot open packfile '%s'", pack_name);
+			die_errno(_("cannot open packfile '%s'"), pack_name);
 		output_fd = -1;
 		pack_fd = input_fd;
 	}
@@ -200,7 +200,7 @@ static void parse_pack_header(void)
 
 	/* Header consistency check */
 	if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
-		die("pack signature mismatch");
+		die(_("pack signature mismatch"));
 	if (!pack_version_ok(hdr->hdr_version))
 		die("pack version %"PRIu32" unsupported",
 			ntohl(hdr->hdr_version));
@@ -220,7 +220,7 @@ static NORETURN void bad_object(unsigned long offset, const char *format, ...)
 	va_start(params, format);
 	vsnprintf(buf, sizeof(buf), format, params);
 	va_end(params);
-	die("pack has bad object at offset %lu: %s", offset, buf);
+	die(_("pack has bad object at offset %lu: %s"), offset, buf);
 }
 
 static struct base_data *alloc_base_data(void)
@@ -294,7 +294,7 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)
 		use(input_len - stream.avail_in);
 	} while (status == Z_OK);
 	if (stream.total_out != size || status != Z_STREAM_END)
-		bad_object(offset, "inflate returned %d", status);
+		bad_object(offset, _("inflate returned %d"), status);
 	git_inflate_end(&stream);
 	return buf;
 }
@@ -339,7 +339,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
 		while (c & 128) {
 			base_offset += 1;
 			if (!base_offset || MSB(base_offset, 7))
-				bad_object(obj->idx.offset, "offset value overflow for delta base object");
+				bad_object(obj->idx.offset, _("offset value overflow for delta base object"));
 			p = fill(1);
 			c = *p;
 			use(1);
@@ -347,7 +347,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
 		}
 		delta_base->offset = obj->idx.offset - base_offset;
 		if (delta_base->offset <= 0 || delta_base->offset >= obj->idx.offset)
-			bad_object(obj->idx.offset, "delta base offset is out of bound");
+			bad_object(obj->idx.offset, _("delta base offset is out of bound"));
 		break;
 	case OBJ_COMMIT:
 	case OBJ_TREE:
@@ -355,7 +355,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
 	case OBJ_TAG:
 		break;
 	default:
-		bad_object(obj->idx.offset, "unknown object type %d", obj->type);
+		bad_object(obj->idx.offset, _("unknown object type %d"), obj->type);
 	}
 	obj->hdr_size = consumed_bytes - obj->idx.offset;
 
@@ -384,9 +384,9 @@ static void *get_data_from_pack(struct object_entry *obj)
 		ssize_t n = (len < 64*1024) ? len : 64*1024;
 		n = pread(pack_fd, inbuf, n, from);
 		if (n < 0)
-			die_errno("cannot pread pack file");
+			die_errno(_("cannot pread pack file"));
 		if (!n)
-			die("premature end of pack file, %lu bytes missing", len);
+			die(_("premature end of pack file, %lu bytes missing"), len);
 		from += n;
 		len -= n;
 		stream.next_in = inbuf;
@@ -396,7 +396,7 @@ static void *get_data_from_pack(struct object_entry *obj)
 
 	/* This has been inflated OK when first encountered, so... */
 	if (status != Z_STREAM_END || stream.total_out != obj->size)
-		die("serious inflate inconsistency");
+		die(_("serious inflate inconsistency"));
 
 	git_inflate_end(&stream);
 	free(inbuf);
@@ -467,10 +467,10 @@ static void sha1_object(const void *data, unsigned long size,
 		unsigned long has_size;
 		has_data = read_sha1_file(sha1, &has_type, &has_size);
 		if (!has_data)
-			die("cannot read existing object %s", sha1_to_hex(sha1));
+			die(_("cannot read existing object %s"), sha1_to_hex(sha1));
 		if (size != has_size || type != has_type ||
 		    memcmp(data, has_data, size) != 0)
-			die("SHA1 COLLISION FOUND WITH %s !", sha1_to_hex(sha1));
+			die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
 		free(has_data);
 	}
 	if (strict) {
@@ -479,7 +479,7 @@ static void sha1_object(const void *data, unsigned long size,
 			if (blob)
 				blob->object.flags |= FLAG_CHECKED;
 			else
-				die("invalid blob object %s", sha1_to_hex(sha1));
+				die(_("invalid blob object %s"), sha1_to_hex(sha1));
 		} else {
 			struct object *obj;
 			int eaten;
@@ -491,11 +491,11 @@ static void sha1_object(const void *data, unsigned long size,
 			 */
 			obj = parse_object_buffer(sha1, type, size, buf, &eaten);
 			if (!obj)
-				die("invalid %s", typename(type));
+				die(_("invalid %s"), typename(type));
 			if (fsck_object(obj, 1, fsck_error_function))
-				die("Error in object");
+				die(_("Error in object"));
 			if (fsck_walk(obj, mark_link, NULL))
-				die("Not all child objects of %s are reachable", sha1_to_hex(obj->sha1));
+				die(_("Not all child objects of %s are reachable"), sha1_to_hex(obj->sha1));
 
 			if (obj->type == OBJ_TREE) {
 				struct tree *item = (struct tree *) obj;
@@ -567,7 +567,7 @@ static void *get_base_data(struct base_data *c)
 				&c->size);
 			free(raw);
 			if (!c->data)
-				bad_object(obj->idx.offset, "failed to apply delta");
+				bad_object(obj->idx.offset, _("failed to apply delta"));
 			base_cache_used += c->size;
 			prune_base_data(c);
 		}
@@ -593,7 +593,7 @@ static void resolve_delta(struct object_entry *delta_obj,
 				   delta_data, delta_obj->size, &result->size);
 	free(delta_data);
 	if (!result->data)
-		bad_object(delta_obj->idx.offset, "failed to apply delta");
+		bad_object(delta_obj->idx.offset, _("failed to apply delta"));
 	sha1_object(result->data, result->size, delta_obj->real_type,
 		    delta_obj->idx.sha1);
 	nr_resolved_deltas++;
@@ -697,7 +697,7 @@ static void parse_pack_objects(unsigned char *sha1)
 	 */
 	if (verbose)
 		progress = start_progress(
-				from_stdin ? "Receiving objects" : "Indexing objects",
+				from_stdin ? _("Receiving objects") : _("Indexing objects"),
 				nr_objects);
 	for (i = 0; i < nr_objects; i++) {
 		struct object_entry *obj = &objects[i];
@@ -719,15 +719,15 @@ static void parse_pack_objects(unsigned char *sha1)
 	flush();
 	git_SHA1_Final(sha1, &input_ctx);
 	if (hashcmp(fill(20), sha1))
-		die("pack is corrupted (SHA1 mismatch)");
+		die(_("pack is corrupted (SHA1 mismatch)"));
 	use(20);
 
 	/* If input_fd is a file, we should have reached its end now. */
 	if (fstat(input_fd, &st))
-		die_errno("cannot fstat packfile");
+		die_errno(_("cannot fstat packfile"));
 	if (S_ISREG(st.st_mode) &&
 			lseek(input_fd, 0, SEEK_CUR) - input_len != st.st_size)
-		die("pack has junk at the end");
+		die(_("pack has junk at the end"));
 
 	if (!nr_deltas)
 		return;
@@ -745,7 +745,7 @@ static void parse_pack_objects(unsigned char *sha1)
 	 *   for some more deltas.
 	 */
 	if (verbose)
-		progress = start_progress("Resolving deltas", nr_deltas);
+		progress = start_progress(_("Resolving deltas"), nr_deltas);
 	for (i = 0; i < nr_objects; i++) {
 		struct object_entry *obj = &objects[i];
 		struct base_data *base_obj = alloc_base_data();
@@ -778,7 +778,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
 	} while (status == Z_OK);
 
 	if (status != Z_STREAM_END)
-		die("unable to deflate appended object (%d)", status);
+		die(_("unable to deflate appended object (%d)"), status);
 	size = stream.total_out;
 	git_deflate_end(&stream);
 	return size;
@@ -857,7 +857,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)
 
 		if (check_sha1_signature(d->base.sha1, base_obj->data,
 				base_obj->size, typename(type)))
-			die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
+			die(_("local object %s is corrupt"), sha1_to_hex(d->base.sha1));
 		base_obj->obj = append_obj_to_pack(f, d->base.sha1,
 					base_obj->data, base_obj->size, type);
 		find_unresolved_deltas(base_obj);
@@ -881,7 +881,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 		fsync_or_die(output_fd, curr_pack_name);
 		err = close(output_fd);
 		if (err)
-			die_errno("error while closing pack file");
+			die_errno(_("error while closing pack file"));
 	}
 
 	if (keep_msg) {
@@ -894,7 +894,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 
 		if (keep_fd < 0) {
 			if (errno != EEXIST)
-				die_errno("cannot write keep file '%s'",
+				die_errno(_("cannot write keep file '%s'"),
 					  keep_name);
 		} else {
 			if (keep_msg_len > 0) {
@@ -902,7 +902,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 				write_or_die(keep_fd, "\n", 1);
 			}
 			if (close(keep_fd) != 0)
-				die_errno("cannot close written keep file '%s'",
+				die_errno(_("cannot close written keep file '%s'"),
 				    keep_name);
 			report = "keep";
 		}
@@ -915,7 +915,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 			final_pack_name = name;
 		}
 		if (move_temp_to_file(curr_pack_name, final_pack_name))
-			die("cannot store pack file");
+			die(_("cannot store pack file"));
 	} else if (from_stdin)
 		chmod(final_pack_name, 0444);
 
@@ -926,7 +926,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
 			final_index_name = name;
 		}
 		if (move_temp_to_file(curr_index_name, final_index_name))
-			die("cannot store index file");
+			die(_("cannot store index file"));
 	} else
 		chmod(final_index_name, 0444);
 
@@ -1015,9 +1015,9 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
 	struct packed_git *p = add_packed_git(pack_name, strlen(pack_name), 1);
 
 	if (!p)
-		die("Cannot open existing pack file '%s'", pack_name);
+		die(_("Cannot open existing pack file '%s'"), pack_name);
 	if (open_pack_index(p))
-		die("Cannot open existing pack idx file for '%s'", pack_name);
+		die(_("Cannot open existing pack idx file for '%s'"), pack_name);
 
 	/* Read the attributes from the existing idx file */
 	opts->version = p->index_version;
@@ -1064,15 +1064,18 @@ static void show_pack_info(int stat_only)
 	}
 
 	if (baseobjects)
-		printf("non delta: %d object%s\n",
-		       baseobjects, baseobjects > 1 ? "s" : "");
+		printf_ln(Q_("non delta: %d object",
+			     "non delta: %d objects",
+			     baseobjects),
+			  baseobjects);
 	for (i = 0; i < deepest_delta; i++) {
 		if (!chain_histogram[i])
 			continue;
-		printf("chain length = %d: %lu object%s\n",
-		       i + 1,
-		       chain_histogram[i],
-		       chain_histogram[i] > 1 ? "s" : "");
+		printf_ln(Q_("chain length = %d: %lu object",
+			     "chain length = %d: %lu objects",
+			     chain_histogram[i]),
+			  i + 1,
+			  chain_histogram[i]);
 	}
 }
 
@@ -1095,7 +1098,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 	reset_pack_idx_option(&opts);
 	git_config(git_index_pack_config, &opts);
 	if (prefix && chdir(prefix))
-		die("Cannot come back to cwd");
+		die(_("Cannot come back to cwd"));
 
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
@@ -1128,10 +1131,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 				hdr->hdr_signature = htonl(PACK_SIGNATURE);
 				hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));
 				if (*c != ',')
-					die("bad %s", arg);
+					die(_("bad %s"), arg);
 				hdr->hdr_entries = htonl(strtoul(c + 1, &c, 10));
 				if (*c)
-					die("bad %s", arg);
+					die(_("bad %s"), arg);
 				input_len = sizeof(*hdr);
 			} else if (!strcmp(arg, "-v")) {
 				verbose = 1;
@@ -1143,11 +1146,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 				char *c;
 				opts.version = strtoul(arg + 16, &c, 10);
 				if (opts.version > 2)
-					die("bad %s", arg);
+					die(_("bad %s"), arg);
 				if (*c == ',')
 					opts.off32_limit = strtoul(c+1, &c, 0);
 				if (*c || opts.off32_limit & 0x80000000)
-					die("bad %s", arg);
+					die(_("bad %s"), arg);
 			} else
 				usage(index_pack_usage);
 			continue;
@@ -1161,11 +1164,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 	if (!pack_name && !from_stdin)
 		usage(index_pack_usage);
 	if (fix_thin_pack && !from_stdin)
-		die("--fix-thin cannot be used without --stdin");
+		die(_("--fix-thin cannot be used without --stdin"));
 	if (!index_name && pack_name) {
 		int len = strlen(pack_name);
 		if (!has_extension(pack_name, ".pack"))
-			die("packfile name '%s' does not end with '.pack'",
+			die(_("packfile name '%s' does not end with '.pack'"),
 			    pack_name);
 		index_name_buf = xmalloc(len);
 		memcpy(index_name_buf, pack_name, len - 5);
@@ -1175,7 +1178,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 	if (keep_msg && !keep_name && pack_name) {
 		int len = strlen(pack_name);
 		if (!has_extension(pack_name, ".pack"))
-			die("packfile name '%s' does not end with '.pack'",
+			die(_("packfile name '%s' does not end with '.pack'"),
 			    pack_name);
 		keep_name_buf = xmalloc(len);
 		memcpy(keep_name_buf, pack_name, len - 5);
@@ -1184,7 +1187,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 	}
 	if (verify) {
 		if (!index_name)
-			die("--verify with no packfile name given");
+			die(_("--verify with no packfile name given"));
 		read_idx_option(&opts, index_name);
 		opts.flags |= WRITE_IDX_VERIFY | WRITE_IDX_STRICT;
 	}
@@ -1208,7 +1211,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 			int nr_unresolved = nr_deltas - nr_resolved_deltas;
 			int nr_objects_initial = nr_objects;
 			if (nr_unresolved <= 0)
-				die("confusion beyond insanity");
+				die(_("confusion beyond insanity"));
 			objects = xrealloc(objects,
 					   (nr_objects + nr_unresolved + 1)
 					   * sizeof(*objects));
@@ -1227,7 +1230,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
 				    "(disk corruption?)", curr_pack);
 		}
 		if (nr_deltas != nr_resolved_deltas)
-			die("pack has %d unresolved deltas",
+			die(_("pack has %d unresolved deltas"),
 			    nr_deltas - nr_resolved_deltas);
 	}
 	free(deltas);
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH i18n 11/11] i18n: bundle: mark strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (9 preceding siblings ...)
  2012-04-16 12:50 ` [PATCH i18n 10/11] i18n: index-pack: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2012-04-16 12:50 ` Nguyễn Thái Ngọc Duy
  2012-04-18 19:40 ` [PATCH i18n 00/11] Mark more " Jonathan Nieder
  11 siblings, 0 replies; 21+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-04-16 12:50 UTC (permalink / raw)
  To: git
  Cc: Ævar Arnfjörð,
	Jiang Xin, Jonathan Nieder,
	Nguyễn Thái Ngọc Duy

---
 bundle.c |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/bundle.c b/bundle.c
index d9cfd90..6d21c77 100644
--- a/bundle.c
+++ b/bundle.c
@@ -33,7 +33,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
 	if (strbuf_getwholeline_fd(&buf, fd, '\n') ||
 	    strcmp(buf.buf, bundle_signature)) {
 		if (report_path)
-			error("'%s' does not look like a v2 bundle file",
+			error(_("'%s' does not look like a v2 bundle file"),
 			      report_path);
 		status = -1;
 		goto abort;
@@ -60,7 +60,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
 		    (40 <= buf.len && !isspace(buf.buf[40])) ||
 		    (!is_prereq && buf.len <= 40)) {
 			if (report_path)
-				error("unrecognized header: %s%s (%d)",
+				error(_("unrecognized header: %s%s (%d)"),
 				      (is_prereq ? "-" : ""), buf.buf, (int)buf.len);
 			status = -1;
 			break;
@@ -86,7 +86,7 @@ int read_bundle_header(const char *path, struct bundle_header *header)
 	int fd = open(path, O_RDONLY);
 
 	if (fd < 0)
-		return error("could not open '%s'", path);
+		return error(_("could not open '%s'"), path);
 	return parse_bundle_header(fd, header, path);
 }
 
@@ -137,7 +137,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	struct object_array refs;
 	struct commit *commit;
 	int i, ret = 0, req_nr;
-	const char *message = "Repository lacks these prerequisite commits:";
+	const char *message = _("Repository lacks these prerequisite commits:");
 
 	init_revisions(&revs, NULL);
 	for (i = 0; i < p->nr; i++) {
@@ -161,7 +161,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	revs.leak_pending = 1;
 
 	if (prepare_revision_walk(&revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	i = req_nr;
 	while (i && (commit = get_revision(&revs)))
@@ -183,12 +183,16 @@ int verify_bundle(struct bundle_header *header, int verbose)
 		struct ref_list *r;
 
 		r = &header->references;
-		printf("The bundle contains %d ref%s\n",
-		       r->nr, (1 < r->nr) ? "s" : "");
+		printf_ln(Q_("The bundle contains %d ref",
+			     "The bundle contains %d refs",
+			     r->nr),
+			  r->nr);
 		list_refs(r, 0, NULL);
 		r = &header->prerequisites;
-		printf("The bundle requires these %d ref%s\n",
-		       r->nr, (1 < r->nr) ? "s" : "");
+		printf_ln(Q_("The bundle requires this ref",
+			     "The bundle requires these %d refs",
+			     r->nr),
+			  r->nr);
 		list_refs(r, 0, NULL);
 	}
 	return ret;
@@ -283,13 +287,13 @@ int create_bundle(struct bundle_header *header, const char *path,
 	strbuf_release(&buf);
 	fclose(rls_fout);
 	if (finish_command(&rls))
-		return error("rev-list died");
+		return error(_("rev-list died"));
 
 	/* write references */
 	argc = setup_revisions(argc, argv, &revs, NULL);
 
 	if (argc > 1)
-		return error("unrecognized argument: %s'", argv[1]);
+		return error(_("unrecognized argument: %s'"), argv[1]);
 
 	object_array_remove_duplicates(&revs.pending);
 
@@ -324,7 +328,7 @@ int create_bundle(struct bundle_header *header, const char *path,
 		 * constraints.
 		 */
 		if (!(e->item->flags & SHOWN) && e->item->type == OBJ_COMMIT) {
-			warning("ref '%s' is excluded by the rev-list options",
+			warning(_("ref '%s' is excluded by the rev-list options"),
 				e->name);
 			free(ref);
 			continue;
@@ -369,7 +373,7 @@ int create_bundle(struct bundle_header *header, const char *path,
 		free(ref);
 	}
 	if (!ref_count)
-		die ("Refusing to create empty bundle.");
+		die(_("Refusing to create empty bundle."));
 
 	/* end header */
 	write_or_die(bundle_fd, "\n", 1);
@@ -387,7 +391,7 @@ int create_bundle(struct bundle_header *header, const char *path,
 	rls.out = bundle_fd;
 	rls.git_cmd = 1;
 	if (start_command(&rls))
-		return error("Could not spawn pack-objects");
+		return error(_("Could not spawn pack-objects"));
 
 	/*
 	 * start_command closed bundle_fd if it was > 1
@@ -405,10 +409,10 @@ int create_bundle(struct bundle_header *header, const char *path,
 	}
 	close(rls.in);
 	if (finish_command(&rls))
-		return error ("pack-objects died");
+		return error(_("pack-objects died"));
 	if (!bundle_to_stdout) {
 		if (commit_lock_file(&lock))
-			die_errno("cannot create '%s'", path);
+			die_errno(_("cannot create '%s'"), path);
 	}
 	return 0;
 }
@@ -430,6 +434,6 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)
 	ip.no_stdout = 1;
 	ip.git_cmd = 1;
 	if (run_command(&ip))
-		return error("index-pack died");
+		return error(_("index-pack died"));
 	return 0;
 }
-- 
1.7.3.1.256.g2539c.dirty

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended
  2012-04-16 12:49 ` [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended Nguyễn Thái Ngọc Duy
@ 2012-04-16 17:26   ` Jonathan Nieder
  2012-04-17  8:12   ` Erik Faye-Lund
  1 sibling, 0 replies; 21+ messages in thread
From: Jonathan Nieder @ 2012-04-16 17:26 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð, Jiang Xin

Nguyễn Thái Ngọc Duy wrote:

>     printf("hello world\n");
>
> can be converted to
>
>     printf_ln(_("hello world"));

Fun.

[...]
> --- a/strbuf.c
> +++ b/strbuf.c
> @@ -464,3 +464,36 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
[...]
> +int printf_ln(const char *fmt, ...)
> +{
> +	int ret;
> +	va_list ap;
> +	va_start(ap, fmt);
> +	ret = vprintf(fmt, ap);
> +	va_end(ap);
> +	if (ret >= 0)
> +		ret += printf("\n");

What happens if the second printf fails?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage
  2012-04-16 12:49 ` [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage Nguyễn Thái Ngọc Duy
@ 2012-04-16 17:54   ` Jonathan Nieder
  2012-04-16 23:35     ` Jonathan Nieder
  0 siblings, 1 reply; 21+ messages in thread
From: Jonathan Nieder @ 2012-04-16 17:54 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð Bjarmason, Jiang Xin

Hi again,

Nguyễn Thái Ngọc Duy wrote:

> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -490,7 +490,7 @@ static int usage_argh(const struct option *opts, FILE *outfile)

The interesting parts in this patch are strings not marked for
translation:

>  			s = literal ? "[%s]" : "[<%s>]";
>  	else
>  		s = literal ? " %s" : " <%s>";

That means the usage message will have one of the formats

	--foo[=<bar>]
	-f[<bar>]
	--foo <bar>
	-f <bar>

in all languages.  Makes sense.

> -	return fprintf(outfile, s, opts->argh ? opts->argh : "...");
> +	return fprintf(outfile, s, opts->argh ? _(opts->argh) : "...");

"bar" becomes "..." in all languages when the caller was too lazy to
fill it in.  I wonder if we should not just require argh to be
non-NULL for options that can take an argument and catch mistakes in
parse_options_check().

> @@ -508,13 +508,12 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
>  	if (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)
>  		fprintf(outfile, "cat <<\\EOF\n");
>  
> -	fprintf(outfile, "usage: %s\n",
> +	fprintf_ln(outfile, _("usage: %s"),

It's too bad this doesn't share code with usage.c. :)  The prompt will
be translated in some contexts and not in others, which seems fine.

> -                                   *usagestr++);
> +                                   _(*usagestr++));

Maybe this change belongs in a separate patch that would mark the
usage strings with N_ at the same time. (*)

>  	while (*usagestr && **usagestr)
> -		fprintf(outfile, "   or: %s\n", *usagestr++);
> +		fprintf_ln(outfile, _("   or: %s"), _(*usagestr++));

Maybe worth a translators note to explain how these line up.

>  	while (*usagestr) {
> -		fprintf(outfile, "%s%s\n",
> -				**usagestr ? "    " : "",
> -				*usagestr);
> +		fprintf(outfile, "%s%s\n", **usagestr ? "    " : "",
> +			_(*usagestr));

Mph, the space is going to look wrong in other languages.

>  		usagestr++;
>  	}
>  
> @@ -528,7 +527,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
>  		if (opts->type == OPTION_GROUP) {
>  			fputc('\n', outfile);
>  			if (*opts->help)
> -				fprintf(outfile, "%s\n", opts->help);
> +				fprintf(outfile, "%s\n", _(opts->help));
[...]
> @@ -558,7 +557,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
>  			fputc('\n', outfile);
>  			pad = USAGE_OPTS_WIDTH;
>  		}
> -		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
> +		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", _(opts->help));
[...]
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -66,12 +66,14 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
>   *
>   * `argh`::
>   *   token to explain the kind of argument this option wants. Keep it
> - *   homogeneous across the repository.
> + *   homogeneous across the repository. Should be wrapped by N_() for
> + *   translation.
>   *
>   * `help`::
>   *   the short help associated to what the option does.
>   *   Must never be NULL (except for OPTION_END).
>   *   OPTION_GROUP uses this pointer to store the group header.
> + *   Should be wrapped by N_() for translation.
[...]
> @@ -158,7 +160,8 @@ struct option {
>  #define OPT_BOOLEAN OPT_COUNTUP
>  
>  /* parse_options() will filter out the processed options and leave the
> - * non-option arguments in argv[].
> + * non-option arguments in argv[]. usagestr strings should be marked
> + * for translation with N_().

Also might be worth splitting into a separate patch that adjusts
callers to use N_ at the same time.  Is there some easy way to catch
strings not in the po template that are passed to gettext() using a
variable (at runtime)?

Thanks for some food for thought.
Jonathan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage
  2012-04-16 17:54   ` Jonathan Nieder
@ 2012-04-16 23:35     ` Jonathan Nieder
  0 siblings, 0 replies; 21+ messages in thread
From: Jonathan Nieder @ 2012-04-16 23:35 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð Bjarmason, Jiang Xin

Jonathan Nieder wrote:
> Nguyễn Thái Ngọc Duy wrote:

>> -                                   *usagestr++);
>> +                                   _(*usagestr++));
>
> Maybe this change belongs in a separate patch that would mark the
> usage strings with N_ at the same time. (*)

I missed that you took care of many of these (e.g., for "git apply")
later in the series.  I wonder if coccinelle could be used to make
the change everywhere at once.

[...]
>                                      Is there some easy way to catch
> strings not in the po template that are passed to gettext() using a
> variable (at runtime)?

If doing that, this kind of sanity check would help catch stragglers.

Jonathan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended
  2012-04-16 12:49 ` [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended Nguyễn Thái Ngọc Duy
  2012-04-16 17:26   ` Jonathan Nieder
@ 2012-04-17  8:12   ` Erik Faye-Lund
  1 sibling, 0 replies; 21+ messages in thread
From: Erik Faye-Lund @ 2012-04-17  8:12 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð, Jiang Xin, Jonathan Nieder

2012/4/16 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
> +int printf_ln(const char *fmt, ...)
> +{
> +       int ret;
> +       va_list ap;
> +       va_start(ap, fmt);
> +       ret = vprintf(fmt, ap);
> +       va_end(ap);
> +       if (ret >= 0)
> +               ret += printf("\n");
<snip>
> +               ret += fprintf(fp, "\n");

Apart from Jonathan's comment, isn't [f]printf a big hammer for this?
Wouldn't putchar / fputc be a tad more light-weight (and perhaps
clearer)?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 05/11] i18n: help: mark strings for translation
  2012-04-16 12:49 ` [PATCH i18n 05/11] i18n: help: mark " Nguyễn Thái Ngọc Duy
@ 2012-04-18 19:30   ` Jonathan Nieder
  0 siblings, 0 replies; 21+ messages in thread
From: Jonathan Nieder @ 2012-04-18 19:30 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð Bjarmason, Jiang Xin

Nguyễn Thái Ngọc Duy wrote:

> This patch also marks most common commands' synopsis for translation
> so that "git help" gives a friendly listing.
[...]
> --- a/Makefile
> +++ b/Makefile
> @@ -2282,7 +2282,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
>  	--keyword=_ --keyword=N_ --keyword="Q_:1,2"
>  XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell
>  XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
> -LOCALIZED_C := $(C_OBJ:o=c)
> +LOCALIZED_C := $(C_OBJ:o=c) common-cmds.h

LOCALIZED_C probably ought to include

	$(LIB_H) branch.h bundle.h bisect.h fetch-pack.h thread-utils.h
	send-pack.h shortlog.h reachable.h wt-status.h tar.h url.h walker.h
	$(XDIFF_H) $(VCSSVN_H)

too, just in case.  This would involve moving the definitions of
XDIFF_H and VCSSVN_H out of the ifndef USE_COMPUTED_HEADER_DEPENDENCIES
block.

Sorry I missed this before.

[...]
> +++ b/git.c
[...]
> @@ -389,6 +397,6 @@ const char *help_unknown_cmd(const char *cmd)
>  
>  int cmd_version(int argc, const char **argv, const char *prefix)
>  {
> -	printf("git version %s\n", git_version_string);
> +	printf_ln(_("git version %s"), git_version_string);
>  	return 0;

An odd one.  I think it's probably best to leave it untranslated for
the sake of i18n-unaware scripts. :(

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 00/11] Mark more strings for translation
  2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (10 preceding siblings ...)
  2012-04-16 12:50 ` [PATCH i18n 11/11] i18n: bundle: " Nguyễn Thái Ngọc Duy
@ 2012-04-18 19:40 ` Jonathan Nieder
  2012-04-22  3:24   ` Nguyen Thai Ngoc Duy
  11 siblings, 1 reply; 21+ messages in thread
From: Jonathan Nieder @ 2012-04-18 19:40 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð Bjarmason, Jiang Xin

Hi,

Nguyễn Thái Ngọc Duy wrote:

> This series marks the following for translations
>
>  - relative dates
>  - git-help (and provide support for translating parseopt)
>  - git-remote
>  - git-index-pack
>  - git-apply
>  - git-bundle
>
> Except git-help, other commands are chosen because they handle plural
> form and I'd like to reuse gettext for that. There are a few conflicts
> with topics on pu, but seem easy to resolve.

My main reaction is that it would be nice to find a way to check that
parseopt users correctly mark their messages for translation while we
remember.  But that doesn't need to block the series.  Ideas about
mechanism from gettext wizards welcome.

Other comments inline.  I expect that there will be at least one
reroll before this is ready.

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 00/11] Mark more strings for translation
  2012-04-18 19:40 ` [PATCH i18n 00/11] Mark more " Jonathan Nieder
@ 2012-04-22  3:24   ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 21+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-04-22  3:24 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Ævar Arnfjörð, Jiang Xin

2012/4/19 Jonathan Nieder <jrnieder@gmail.com>:
> My main reaction is that it would be nice to find a way to check that
> parseopt users correctly mark their messages for translation while we
> remember.  But that doesn't need to block the series.  Ideas about
> mechanism from gettext wizards welcome.

How about we use msgen on git.pot to produce all-translated .po file.
Then gettext(foo) would return foo if the translation is not found
(i.e. the string not marked). Now I don't know how we force loading
this special .mo file..
-- 
Duy

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence
  2012-04-16 12:50 ` [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence Nguyễn Thái Ngọc Duy
@ 2012-04-22 16:42   ` Zbigniew Jędrzejewski-Szmek
  2012-04-23 11:33     ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 21+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-04-22 16:42 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git, Ævar Arnfjörð, Jiang Xin, Jonathan Nieder

On 04/16/2012 02:50 PM, Nguyễn Thái Ngọc Duy wrote:
> ---
>  builtin/apply.c |   33 +++++++++++++++++++--------------
>  1 files changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/builtin/apply.c b/builtin/apply.c
> index 6e9a02e..87922cf 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -335,22 +335,25 @@ static void clear_image(struct image *image)
>  	image->len = 0;
>  }
>  
> -static void say_patch_name(FILE *output, const char *pre,
> -			   struct patch *patch, const char *post)
> +/* fmt must contain _one_ %s and no other substitution */
> +static void say_patch_name(FILE *output, struct patch *patch, const char *fmt)
>  {
> -	fputs(pre, output);
> +	struct strbuf sb = STRBUF_INIT;
> +
>  	if (patch->old_name && patch->new_name &&
>  	    strcmp(patch->old_name, patch->new_name)) {
> -		quote_c_style(patch->old_name, NULL, output, 0);
> -		fputs(" => ", output);
> -		quote_c_style(patch->new_name, NULL, output, 0);
> +		quote_c_style(patch->old_name, &sb, NULL, 0);
> +		strbuf_addstr(&sb, " => ");
> +		quote_c_style(patch->new_name, &sb, NULL, 0);
>  	} else {
>  		const char *n = patch->new_name;
>  		if (!n)
>  			n = patch->old_name;
> -		quote_c_style(n, NULL, output, 0);
> +		quote_c_style(n, &sb, NULL, 0);
>  	}
> -	fputs(post, output);
> +	fprintf(output, fmt, sb.buf);
> +	fprintf(output, "\n");
> +	strbuf_release(&sb);
>  }
>  
>  #define CHUNKSIZE (8192)
> @@ -3165,8 +3168,8 @@ static int check_patch_list(struct patch *patch)
>  	prepare_fn_table(patch);
>  	while (patch) {
>  		if (apply_verbosely)
> -			say_patch_name(stderr,
> -				       "Checking patch ", patch, "...\n");
> +			say_patch_name(stderr, patch,
> +				       _("Checking patch %s..."));
>  		err |= check_patch(patch);
>  		patch = patch->next;
>  	}
> @@ -3530,6 +3533,7 @@ static int write_out_one_reject(struct patch *patch)
>  	char namebuf[PATH_MAX];
>  	struct fragment *frag;
>  	int cnt = 0;
> +	struct strbuf sb = STRBUF_INIT;
>  
>  	for (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {
>  		if (!frag->rejected)
> @@ -3539,8 +3543,8 @@ static int write_out_one_reject(struct patch *patch)
>  
>  	if (!cnt) {
>  		if (apply_verbosely)
> -			say_patch_name(stderr,
> -				       "Applied patch ", patch, " cleanly.\n");
> +			say_patch_name(stderr, patch,
> +				       _("Applied patch %s cleanly."));
>  		return 0;
>  	}
>  
> @@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)
>  		die(_("internal error"));
>  
>  	/* Say this even without --verbose */
> -	say_patch_name(stderr, "Applying patch ", patch, " with");
> -	fprintf(stderr, " %d rejects...\n", cnt);
> +	strbuf_addf(&sb, _("Applying patch %%s with %d rejects..."), cnt);
Shouldn't this part be:
        strbuf_addf(&sb, Q_("Applying patch %%s with one reject...",
                            "Applying patch %%s with %d rejects...",
                            cnt), cnt);
?

-
Zbyszek

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence
  2012-04-22 16:42   ` Zbigniew Jędrzejewski-Szmek
@ 2012-04-23 11:33     ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 21+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-04-23 11:33 UTC (permalink / raw)
  To: Zbigniew Jędrzejewski-Szmek
  Cc: git, Ævar Arnfjörð, Jiang Xin, Jonathan Nieder

On Sun, Apr 22, 2012 at 11:42 PM, Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl> wrote:
> On 04/16/2012 02:50 PM, Nguyễn Thái Ngọc Duy wrote:
>> @@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)
>>               die(_("internal error"));
>>
>>       /* Say this even without --verbose */
>> -     say_patch_name(stderr, "Applying patch ", patch, " with");
>> -     fprintf(stderr, " %d rejects...\n", cnt);
>> +     strbuf_addf(&sb, _("Applying patch %%s with %d rejects..."), cnt);
> Shouldn't this part be:
>        strbuf_addf(&sb, Q_("Applying patch %%s with one reject...",
>                            "Applying patch %%s with %d rejects...",
>                            cnt), cnt);
> ?

Yes. Thanks for catching.
-- 
Duy

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2012-04-23 11:33 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-16 12:49 [PATCH i18n 00/11] Mark more strings for translation Nguyễn Thái Ngọc Duy
2012-04-16 12:49 ` [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended Nguyễn Thái Ngọc Duy
2012-04-16 17:26   ` Jonathan Nieder
2012-04-17  8:12   ` Erik Faye-Lund
2012-04-16 12:49 ` [PATCH i18n 02/11] i18n: mark relative dates for translation Nguyễn Thái Ngọc Duy
2012-04-16 12:49 ` [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage Nguyễn Thái Ngọc Duy
2012-04-16 17:54   ` Jonathan Nieder
2012-04-16 23:35     ` Jonathan Nieder
2012-04-16 12:49 ` [PATCH i18n 04/11] i18n: help: mark parseopt strings for translation Nguyễn Thái Ngọc Duy
2012-04-16 12:49 ` [PATCH i18n 05/11] i18n: help: mark " Nguyễn Thái Ngọc Duy
2012-04-18 19:30   ` Jonathan Nieder
2012-04-16 12:49 ` [PATCH i18n 06/11] i18n: make warn_dangling_symref() automatically append \n Nguyễn Thái Ngọc Duy
2012-04-16 12:49 ` [PATCH i18n 07/11] i18n: remote: mark strings for translation Nguyễn Thái Ngọc Duy
2012-04-16 12:50 ` [PATCH i18n 08/11] i18n: apply: " Nguyễn Thái Ngọc Duy
2012-04-16 12:50 ` [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence Nguyễn Thái Ngọc Duy
2012-04-22 16:42   ` Zbigniew Jędrzejewski-Szmek
2012-04-23 11:33     ` Nguyen Thai Ngoc Duy
2012-04-16 12:50 ` [PATCH i18n 10/11] i18n: index-pack: mark strings for translation Nguyễn Thái Ngọc Duy
2012-04-16 12:50 ` [PATCH i18n 11/11] i18n: bundle: " Nguyễn Thái Ngọc Duy
2012-04-18 19:40 ` [PATCH i18n 00/11] Mark more " Jonathan Nieder
2012-04-22  3:24   ` Nguyen Thai Ngoc Duy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.