{"thread":{"id":"30259","subject":"[PATCH i18n 00/11] Mark more strings for translation","startedAt":"2012-04-16T12:49:52Z","lastAt":"2012-04-23T11:33:22Z","messageCount":21,"participants":["Nguyễn Thái Ngọc Duy","Jonathan Nieder","Erik Faye-Lund","Nguyen Thai Ngoc Duy","Zbigniew Jędrzejewski-Szmek"],"isPatch":true,"patchVersion":1,"patchTotal":11},"messages":[{"id":"189392","messageId":"1334580603-11577-1-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":null,"subject":"[PATCH i18n 00/11] Mark more strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:52Z","receivedAt":"2012-04-16T12:49:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This series marks the following for translations\n\n - relative dates\n - git-help (and provide support for translating parseopt)\n - git-remote\n - git-index-pack\n - git-apply\n - git-bundle\n\nExcept git-help, other commands are chosen because they handle plural\nform and I'd like to reuse gettext for that. There are a few conflicts\nwith topics on pu, but seem easy to resolve.\n\nJonathan Nieder (1):\n  i18n: mark relative dates for translation\n\nNguyễn Thái Ngọc Duy (10):\n  Add three convenient format printing functions with \\n automatically appended\n  i18n: parseopt: lookup help and argument translations when showing usage\n  i18n: help: mark parseopt strings for translation\n  i18n: help: mark strings for translation\n  i18n: make warn_dangling_symref() automatically append \\n\n  i18n: remote: mark strings for translation\n  i18n: apply: mark strings for translation\n  i18n: apply: update say_patch_name to give translators complete sentence\n  i18n: index-pack: mark strings for translation\n  i18n: bundle: mark strings for translation\n\n Makefile             |    2 +-\n builtin/apply.c      |  259 ++++++++++++++++++++++++++------------------------\n builtin/fetch.c      |    4 +-\n builtin/help.c       |   58 ++++++------\n builtin/index-pack.c |  117 ++++++++++++-----------\n builtin/remote.c     |  252 ++++++++++++++++++++++++++-----------------------\n bundle.c             |   38 ++++----\n cache.h              |    6 +-\n date.c               |   95 +++++++++++--------\n generate-cmdlist.sh  |    2 +-\n git.c                |    2 +-\n help.c               |   34 ++++---\n parse-options.c      |   15 ++--\n parse-options.h      |    7 +-\n refs.c               |    1 +\n strbuf.c             |   33 +++++++\n strbuf.h             |    7 ++\n test-date.c          |    7 +-\n 18 files changed, 517 insertions(+), 422 deletions(-)\n\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189393","messageId":"1334580603-11577-2-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 01/11] Add three convenient format printing functions with \\n automatically appended","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:53Z","receivedAt":"2012-04-16T12:49:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"These functions are helpful when we do not want to expose \\n to\ntranslators. For example\n\n    printf(\"hello world\\n\");\n\ncan be converted to\n\n    printf_ln(_(\"hello world\"));\n---\n strbuf.c |   33 +++++++++++++++++++++++++++++++++\n strbuf.h |    7 +++++++\n 2 files changed, 40 insertions(+), 0 deletions(-)\n\ndiff --git a/strbuf.c b/strbuf.c\nindex 5135d59..9fbc75c 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -464,3 +464,36 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,\n {\n \tstrbuf_add_urlencode(sb, s, strlen(s), reserved);\n }\n+\n+void strbuf_addf_ln(struct strbuf *sb, const char *fmt, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, fmt);\n+\tstrbuf_vaddf(sb, fmt, ap);\n+\tva_end(ap);\n+\tstrbuf_addch(sb, '\\n');\n+}\n+\n+int printf_ln(const char *fmt, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\tva_start(ap, fmt);\n+\tret = vprintf(fmt, ap);\n+\tva_end(ap);\n+\tif (ret >= 0)\n+\t\tret += printf(\"\\n\");\n+\treturn ret;\n+}\n+\n+int fprintf_ln(FILE *fp, const char *fmt, ...)\n+{\n+\tint ret;\n+\tva_list ap;\n+\tva_start(ap, fmt);\n+\tret = vfprintf(fp, fmt, ap);\n+\tva_end(ap);\n+\tif (ret >= 0)\n+\t\tret += fprintf(fp, \"\\n\");\n+\treturn ret;\n+}\ndiff --git a/strbuf.h b/strbuf.h\nindex 3effaa8..b888d40 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -99,6 +99,8 @@ __attribute__((format (printf,2,3)))\n extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);\n __attribute__((format (printf,2,0)))\n extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);\n+__attribute__((format (printf,2,3)))\n+extern void strbuf_addf_ln(struct strbuf *sb, const char *fmt, ...);\n \n extern void strbuf_add_lines(struct strbuf *sb, const char *prefix, const char *buf, size_t size);\n \n@@ -129,4 +131,9 @@ extern void strbuf_add_urlencode(struct strbuf *, const char *, size_t,\n extern void strbuf_addstr_urlencode(struct strbuf *, const char *,\n \t\t\t\t    int reserved);\n \n+__attribute__((format (printf,1,2)))\n+extern int printf_ln(const char *fmt, ...);\n+__attribute__((format (printf,2,3)))\n+extern int fprintf_ln(FILE *fp, const char *fmt, ...);\n+\n #endif /* STRBUF_H */\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189394","messageId":"1334580603-11577-3-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 02/11] i18n: mark relative dates for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:54Z","receivedAt":"2012-04-16T12:49:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n cache.h     |    6 +--\n date.c      |   95 ++++++++++++++++++++++++++++++++++------------------------\n test-date.c |    7 ++--\n 3 files changed, 62 insertions(+), 46 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex a8aceb5..aa9f8f9 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -906,10 +906,8 @@ enum date_mode {\n };\n \n const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n-const char *show_date_relative(unsigned long time, int tz,\n-\t\t\t       const struct timeval *now,\n-\t\t\t       char *timebuf,\n-\t\t\t       size_t timebuf_size);\n+void show_date_relative(unsigned long time, int tz, const struct timeval *now,\n+\t\t\tstruct strbuf *timebuf);\n int parse_date(const char *date, char *buf, int bufsize);\n int parse_date_basic(const char *date, unsigned long *timestamp, int *offset);\n void datestamp(char *buf, int bufsize);\ndiff --git a/date.c b/date.c\nindex a5055ca..1fdcf7c 100644\n--- a/date.c\n+++ b/date.c\n@@ -86,83 +86,98 @@ static int local_tzoffset(unsigned long time)\n \treturn offset * eastwest;\n }\n \n-const char *show_date_relative(unsigned long time, int tz,\n+void show_date_relative(unsigned long time, int tz,\n \t\t\t       const struct timeval *now,\n-\t\t\t       char *timebuf,\n-\t\t\t       size_t timebuf_size)\n+\t\t\t       struct strbuf *timebuf)\n {\n \tunsigned long diff;\n-\tif (now->tv_sec < time)\n-\t\treturn \"in the future\";\n+\tif (now->tv_sec < time) {\n+\t\tstrbuf_addstr(timebuf, _(\"in the future\"));\n+\t\treturn;\n+\t}\n \tdiff = now->tv_sec - time;\n \tif (diff < 90) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu seconds ago\", diff);\n-\t\treturn timebuf;\n+\t\tstrbuf_addf(timebuf,\n+\t\t\t Q_(\"%lu second ago\", \"%lu seconds ago\", diff), diff);\n+\t\treturn;\n \t}\n \t/* Turn it into minutes */\n \tdiff = (diff + 30) / 60;\n \tif (diff < 90) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu minutes ago\", diff);\n-\t\treturn timebuf;\n+\t\tstrbuf_addf(timebuf,\n+\t\t\t Q_(\"%lu minute ago\", \"%lu minutes ago\", diff), diff);\n+\t\treturn;\n \t}\n \t/* Turn it into hours */\n \tdiff = (diff + 30) / 60;\n \tif (diff < 36) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu hours ago\", diff);\n-\t\treturn timebuf;\n+\t\tstrbuf_addf(timebuf,\n+\t\t\t Q_(\"%lu hour ago\", \"%lu hours ago\", diff), diff);\n+\t\treturn;\n \t}\n \t/* We deal with number of days from here on */\n \tdiff = (diff + 12) / 24;\n \tif (diff < 14) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu days ago\", diff);\n-\t\treturn timebuf;\n+\t\tstrbuf_addf(timebuf,\n+\t\t\t Q_(\"%lu day ago\", \"%lu days ago\", diff), diff);\n+\t\treturn;\n \t}\n \t/* Say weeks for the past 10 weeks or so */\n \tif (diff < 70) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu weeks ago\", (diff + 3) / 7);\n-\t\treturn timebuf;\n+\t\tstrbuf_addf(timebuf,\n+\t\t\t Q_(\"%lu week ago\", \"%lu weeks ago\", (diff + 3) / 7),\n+\t\t\t (diff + 3) / 7);\n+\t\treturn;\n \t}\n \t/* Say months for the past 12 months or so */\n \tif (diff < 365) {\n-\t\tsnprintf(timebuf, timebuf_size, \"%lu months ago\", (diff + 15) / 30);\n-\t\treturn timebuf;\n+\t\tstrbuf_addf(timebuf,\n+\t\t\t Q_(\"%lu month ago\", \"%lu months ago\", (diff + 15) / 30),\n+\t\t\t (diff + 15) / 30);\n+\t\treturn;\n \t}\n \t/* Give years and months for 5 years or so */\n \tif (diff < 1825) {\n \t\tunsigned long totalmonths = (diff * 12 * 2 + 365) / (365 * 2);\n \t\tunsigned long years = totalmonths / 12;\n \t\tunsigned long months = totalmonths % 12;\n-\t\tint n;\n-\t\tn = snprintf(timebuf, timebuf_size, \"%lu year%s\",\n-\t\t\t\tyears, (years > 1 ? \"s\" : \"\"));\n-\t\tif (months)\n-\t\t\tsnprintf(timebuf + n, timebuf_size - n,\n-\t\t\t\t\t\", %lu month%s ago\",\n-\t\t\t\t\tmonths, (months > 1 ? \"s\" : \"\"));\n-\t\telse\n-\t\t\tsnprintf(timebuf + n, timebuf_size - n, \" ago\");\n-\t\treturn timebuf;\n+\t\tif (months) {\n+\t\t\tstruct strbuf sb = STRBUF_INIT;\n+\t\t\tstrbuf_addf(&sb, Q_(\"%lu year\", \"%lu years\", years), years);\n+\t\t\t/* TRANSLATORS: \"%s\" is \"<n> years\" */\n+\t\t\tstrbuf_addf(timebuf,\n+\t\t\t\t Q_(\"%s, %lu month ago\", \"%s, %lu months ago\", months),\n+\t\t\t\t sb.buf, months);\n+\t\t\tstrbuf_release(&sb);\n+\t\t} else\n+\t\t\tstrbuf_addf(timebuf,\n+\t\t\t\t Q_(\"%lu year ago\", \"%lu years ago\", years), years);\n+\t\treturn;\n \t}\n \t/* Otherwise, just years. Centuries is probably overkill. */\n-\tsnprintf(timebuf, timebuf_size, \"%lu years ago\", (diff + 183) / 365);\n-\treturn timebuf;\n+\tstrbuf_addf(timebuf,\n+\t\t Q_(\"%lu year ago\", \"%lu years ago\", (diff + 183) / 365),\n+\t\t (diff + 183) / 365);\n }\n \n const char *show_date(unsigned long time, int tz, enum date_mode mode)\n {\n \tstruct tm *tm;\n-\tstatic char timebuf[200];\n+\tstatic struct strbuf timebuf = STRBUF_INIT;\n \n \tif (mode == DATE_RAW) {\n-\t\tsnprintf(timebuf, sizeof(timebuf), \"%lu %+05d\", time, tz);\n-\t\treturn timebuf;\n+\t\tstrbuf_reset(&timebuf);\n+\t\tstrbuf_addf(&timebuf, \"%lu %+05d\", time, tz);\n+\t\treturn timebuf.buf;\n \t}\n \n \tif (mode == DATE_RELATIVE) {\n \t\tstruct timeval now;\n+\n+\t\tstrbuf_reset(&timebuf);\n \t\tgettimeofday(&now, NULL);\n-\t\treturn show_date_relative(time, tz, &now,\n-\t\t\t\t\t  timebuf, sizeof(timebuf));\n+\t\tshow_date_relative(time, tz, &now, &timebuf);\n+\t\treturn timebuf.buf;\n \t}\n \n \tif (mode == DATE_LOCAL)\n@@ -171,23 +186,25 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \ttm = time_to_tm(time, tz);\n \tif (!tm)\n \t\treturn NULL;\n+\n+\tstrbuf_reset(&timebuf);\n \tif (mode == DATE_SHORT)\n-\t\tsprintf(timebuf, \"%04d-%02d-%02d\", tm->tm_year + 1900,\n+\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02d\", tm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1, tm->tm_mday);\n \telse if (mode == DATE_ISO8601)\n-\t\tsprintf(timebuf, \"%04d-%02d-%02d %02d:%02d:%02d %+05d\",\n+\t\tstrbuf_addf(&timebuf, \"%04d-%02d-%02d %02d:%02d:%02d %+05d\",\n \t\t\t\ttm->tm_year + 1900,\n \t\t\t\ttm->tm_mon + 1,\n \t\t\t\ttm->tm_mday,\n \t\t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec,\n \t\t\t\ttz);\n \telse if (mode == DATE_RFC2822)\n-\t\tsprintf(timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n+\t\tstrbuf_addf(&timebuf, \"%.3s, %d %.3s %d %02d:%02d:%02d %+05d\",\n \t\t\tweekday_names[tm->tm_wday], tm->tm_mday,\n \t\t\tmonth_names[tm->tm_mon], tm->tm_year + 1900,\n \t\t\ttm->tm_hour, tm->tm_min, tm->tm_sec, tz);\n \telse\n-\t\tsprintf(timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n+\t\tstrbuf_addf(&timebuf, \"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d\",\n \t\t\t\tweekday_names[tm->tm_wday],\n \t\t\t\tmonth_names[tm->tm_mon],\n \t\t\t\ttm->tm_mday,\n@@ -195,7 +212,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)\n \t\t\t\ttm->tm_year + 1900,\n \t\t\t\t(mode == DATE_LOCAL) ? 0 : ' ',\n \t\t\t\ttz);\n-\treturn timebuf;\n+\treturn timebuf.buf;\n }\n \n /*\ndiff --git a/test-date.c b/test-date.c\nindex 6bcd5b0..10afaab 100644\n--- a/test-date.c\n+++ b/test-date.c\n@@ -7,13 +7,14 @@ static const char *usage_msg = \"\\n\"\n \n static void show_dates(char **argv, struct timeval *now)\n {\n-\tchar buf[128];\n+\tstruct strbuf buf = STRBUF_INIT;\n \n \tfor (; *argv; argv++) {\n \t\ttime_t t = atoi(*argv);\n-\t\tshow_date_relative(t, 0, now, buf, sizeof(buf));\n-\t\tprintf(\"%s -> %s\\n\", *argv, buf);\n+\t\tshow_date_relative(t, 0, now, &buf);\n+\t\tprintf(\"%s -> %s\\n\", *argv, buf.buf);\n \t}\n+\tstrbuf_release(&buf);\n }\n \n static void parse_dates(char **argv, struct timeval *now)\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189395","messageId":"1334580603-11577-4-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:55Z","receivedAt":"2012-04-16T12:49:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n parse-options.c |   15 +++++++--------\n parse-options.h |    7 +++++--\n 2 files changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex 850cfa7..7690de8 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -490,7 +490,7 @@ static int usage_argh(const struct option *opts, FILE *outfile)\n \t\t\ts = literal ? \"[%s]\" : \"[<%s>]\";\n \telse\n \t\ts = literal ? \" %s\" : \" <%s>\";\n-\treturn fprintf(outfile, s, opts->argh ? opts->argh : \"...\");\n+\treturn fprintf(outfile, s, opts->argh ? _(opts->argh) : \"...\");\n }\n \n #define USAGE_OPTS_WIDTH 24\n@@ -508,13 +508,12 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \tif (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)\n \t\tfprintf(outfile, \"cat <<\\\\EOF\\n\");\n \n-\tfprintf(outfile, \"usage: %s\\n\", *usagestr++);\n+\tfprintf_ln(outfile, _(\"usage: %s\"), _(*usagestr++));\n \twhile (*usagestr && **usagestr)\n-\t\tfprintf(outfile, \"   or: %s\\n\", *usagestr++);\n+\t\tfprintf_ln(outfile, _(\"   or: %s\"), _(*usagestr++));\n \twhile (*usagestr) {\n-\t\tfprintf(outfile, \"%s%s\\n\",\n-\t\t\t\t**usagestr ? \"    \" : \"\",\n-\t\t\t\t*usagestr);\n+\t\tfprintf(outfile, \"%s%s\\n\", **usagestr ? \"    \" : \"\",\n+\t\t\t_(*usagestr));\n \t\tusagestr++;\n \t}\n \n@@ -528,7 +527,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \t\tif (opts->type == OPTION_GROUP) {\n \t\t\tfputc('\\n', outfile);\n \t\t\tif (*opts->help)\n-\t\t\t\tfprintf(outfile, \"%s\\n\", opts->help);\n+\t\t\t\tfprintf(outfile, \"%s\\n\", _(opts->help));\n \t\t\tcontinue;\n \t\t}\n \t\tif (!full && (opts->flags & PARSE_OPT_HIDDEN))\n@@ -558,7 +557,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \t\t\tfputc('\\n', outfile);\n \t\t\tpad = USAGE_OPTS_WIDTH;\n \t\t}\n-\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\", opts->help);\n+\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\", _(opts->help));\n \t}\n \tfputc('\\n', outfile);\n \ndiff --git a/parse-options.h b/parse-options.h\nindex def9ced..4e59f2c 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -66,12 +66,14 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n  *\n  * `argh`::\n  *   token to explain the kind of argument this option wants. Keep it\n- *   homogeneous across the repository.\n+ *   homogeneous across the repository. Should be wrapped by N_() for\n+ *   translation.\n  *\n  * `help`::\n  *   the short help associated to what the option does.\n  *   Must never be NULL (except for OPTION_END).\n  *   OPTION_GROUP uses this pointer to store the group header.\n+ *   Should be wrapped by N_() for translation.\n  *\n  * `flags`::\n  *   mask of parse_opt_option_flags.\n@@ -158,7 +160,8 @@ struct option {\n #define OPT_BOOLEAN OPT_COUNTUP\n \n /* parse_options() will filter out the processed options and leave the\n- * non-option arguments in argv[].\n+ * non-option arguments in argv[]. usagestr strings should be marked\n+ * for translation with N_().\n  * Returns the number of arguments left in argv[].\n  */\n extern int parse_options(int argc, const char **argv, const char *prefix,\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189396","messageId":"1334580603-11577-5-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 04/11] i18n: help: mark parseopt strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:56Z","receivedAt":"2012-04-16T12:49:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n builtin/help.c |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 61ff798..22756bd 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -32,17 +32,17 @@ enum help_format {\n static int show_all = 0;\n static enum help_format help_format = HELP_FORMAT_NONE;\n static struct option builtin_help_options[] = {\n-\tOPT_BOOLEAN('a', \"all\", &show_all, \"print all available commands\"),\n-\tOPT_SET_INT('m', \"man\", &help_format, \"show man page\", HELP_FORMAT_MAN),\n-\tOPT_SET_INT('w', \"web\", &help_format, \"show manual in web browser\",\n+\tOPT_BOOLEAN('a', \"all\", &show_all, N_(\"print all available commands\")),\n+\tOPT_SET_INT('m', \"man\", &help_format, N_(\"show man page\"), HELP_FORMAT_MAN),\n+\tOPT_SET_INT('w', \"web\", &help_format, N_(\"show manual in web browser\"),\n \t\t\tHELP_FORMAT_WEB),\n-\tOPT_SET_INT('i', \"info\", &help_format, \"show info page\",\n+\tOPT_SET_INT('i', \"info\", &help_format, N_(\"show info page\"),\n \t\t\tHELP_FORMAT_INFO),\n \tOPT_END(),\n };\n \n static const char * const builtin_help_usage[] = {\n-\t\"git help [--all] [--man|--web|--info] [command]\",\n+\tN_(\"git help [--all] [--man|--web|--info] [command]\"),\n \tNULL\n };\n \n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189397","messageId":"1334580603-11577-6-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 05/11] i18n: help: mark strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:57Z","receivedAt":"2012-04-16T12:49:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This patch also marks most common commands' synopsis for translation\nso that \"git help\" gives a friendly listing.\n---\n Makefile            |    2 +-\n builtin/help.c      |   48 ++++++++++++++++++++++++------------------------\n generate-cmdlist.sh |    2 +-\n git.c               |    2 +-\n help.c              |   34 +++++++++++++++++++++-------------\n 5 files changed, 48 insertions(+), 40 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex be1957a..34cf971 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2282,7 +2282,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n \t--keyword=_ --keyword=N_ --keyword=\"Q_:1,2\"\n XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell\n XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl\n-LOCALIZED_C := $(C_OBJ:o=c)\n+LOCALIZED_C := $(C_OBJ:o=c) common-cmds.h\n LOCALIZED_SH := $(SCRIPT_SH)\n LOCALIZED_PERL := $(SCRIPT_PERL)\n \ndiff --git a/builtin/help.c b/builtin/help.c\nindex 22756bd..ab6bbf4 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -54,7 +54,7 @@ static enum help_format parse_help_format(const char *format)\n \t\treturn HELP_FORMAT_INFO;\n \tif (!strcmp(format, \"web\") || !strcmp(format, \"html\"))\n \t\treturn HELP_FORMAT_WEB;\n-\tdie(\"unrecognized help format '%s'\", format);\n+\tdie(_(\"unrecognized help format '%s'\"), format);\n }\n \n static const char *get_man_viewer_info(const char *name)\n@@ -82,7 +82,7 @@ static int check_emacsclient_version(void)\n \tec_process.err = -1;\n \tec_process.stdout_to_stderr = 1;\n \tif (start_command(&ec_process))\n-\t\treturn error(\"Failed to start emacsclient.\");\n+\t\treturn error(_(\"Failed to start emacsclient.\"));\n \n \tstrbuf_read(&buffer, ec_process.err, 20);\n \tclose(ec_process.err);\n@@ -95,7 +95,7 @@ static int check_emacsclient_version(void)\n \n \tif (prefixcmp(buffer.buf, \"emacsclient\")) {\n \t\tstrbuf_release(&buffer);\n-\t\treturn error(\"Failed to parse emacsclient version.\");\n+\t\treturn error(_(\"Failed to parse emacsclient version.\"));\n \t}\n \n \tstrbuf_remove(&buffer, 0, strlen(\"emacsclient\"));\n@@ -103,7 +103,7 @@ static int check_emacsclient_version(void)\n \n \tif (version < 22) {\n \t\tstrbuf_release(&buffer);\n-\t\treturn error(\"emacsclient version '%d' too old (< 22).\",\n+\t\treturn error(_(\"emacsclient version '%d' too old (< 22).\"),\n \t\t\tversion);\n \t}\n \n@@ -121,7 +121,7 @@ static void exec_woman_emacs(const char *path, const char *page)\n \t\t\tpath = \"emacsclient\";\n \t\tstrbuf_addf(&man_page, \"(woman \\\"%s\\\")\", page);\n \t\texeclp(path, \"emacsclient\", \"-e\", man_page.buf, (char *)NULL);\n-\t\twarning(\"failed to exec '%s': %s\", path, strerror(errno));\n+\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n \t}\n }\n \n@@ -149,7 +149,7 @@ static void exec_man_konqueror(const char *path, const char *page)\n \t\t\tpath = \"kfmclient\";\n \t\tstrbuf_addf(&man_page, \"man:%s(1)\", page);\n \t\texeclp(path, filename, \"newTab\", man_page.buf, (char *)NULL);\n-\t\twarning(\"failed to exec '%s': %s\", path, strerror(errno));\n+\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n \t}\n }\n \n@@ -158,7 +158,7 @@ static void exec_man_man(const char *path, const char *page)\n \tif (!path)\n \t\tpath = \"man\";\n \texeclp(path, \"man\", page, (char *)NULL);\n-\twarning(\"failed to exec '%s': %s\", path, strerror(errno));\n+\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n }\n \n static void exec_man_cmd(const char *cmd, const char *page)\n@@ -166,7 +166,7 @@ static void exec_man_cmd(const char *cmd, const char *page)\n \tstruct strbuf shell_cmd = STRBUF_INIT;\n \tstrbuf_addf(&shell_cmd, \"%s %s\", cmd, page);\n \texecl(\"/bin/sh\", \"sh\", \"-c\", shell_cmd.buf, (char *)NULL);\n-\twarning(\"failed to exec '%s': %s\", cmd, strerror(errno));\n+\twarning(_(\"failed to exec '%s': %s\"), cmd, strerror(errno));\n }\n \n static void add_man_viewer(const char *name)\n@@ -206,8 +206,8 @@ static int add_man_viewer_path(const char *name,\n \tif (supported_man_viewer(name, len))\n \t\tdo_add_man_viewer_info(name, len, value);\n \telse\n-\t\twarning(\"'%s': path for unsupported man viewer.\\n\"\n-\t\t\t\"Please consider using 'man.<tool>.cmd' instead.\",\n+\t\twarning(_(\"'%s': path for unsupported man viewer.\\n\"\n+\t\t\t  \"Please consider using 'man.<tool>.cmd' instead.\"),\n \t\t\tname);\n \n \treturn 0;\n@@ -218,8 +218,8 @@ static int add_man_viewer_cmd(const char *name,\n \t\t\t      const char *value)\n {\n \tif (supported_man_viewer(name, len))\n-\t\twarning(\"'%s': cmd for supported man viewer.\\n\"\n-\t\t\t\"Please consider using 'man.<tool>.path' instead.\",\n+\t\twarning(_(\"'%s': cmd for supported man viewer.\\n\"\n+\t\t\t  \"Please consider using 'man.<tool>.path' instead.\"),\n \t\t\tname);\n \telse\n \t\tdo_add_man_viewer_info(name, len, value);\n@@ -280,11 +280,11 @@ void list_common_cmds_help(void)\n \t\t\tlongest = strlen(common_cmds[i].name);\n \t}\n \n-\tputs(\"The most commonly used git commands are:\");\n+\tputs(_(\"The most commonly used git commands are:\"));\n \tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n \t\tprintf(\"   %s   \", common_cmds[i].name);\n \t\tmput_char(' ', longest - strlen(common_cmds[i].name));\n-\t\tputs(common_cmds[i].help);\n+\t\tputs(_(common_cmds[i].help));\n \t}\n }\n \n@@ -348,7 +348,7 @@ static void exec_viewer(const char *name, const char *page)\n \telse if (info)\n \t\texec_man_cmd(info, page);\n \telse\n-\t\twarning(\"'%s': unknown man viewer.\", name);\n+\t\twarning(_(\"'%s': unknown man viewer.\"), name);\n }\n \n static void show_man_page(const char *git_cmd)\n@@ -365,7 +365,7 @@ static void show_man_page(const char *git_cmd)\n \tif (fallback)\n \t\texec_viewer(fallback, page);\n \texec_viewer(\"man\", page);\n-\tdie(\"no man viewer handled the request\");\n+\tdie(_(\"no man viewer handled the request\"));\n }\n \n static void show_info_page(const char *git_cmd)\n@@ -373,7 +373,7 @@ static void show_info_page(const char *git_cmd)\n \tconst char *page = cmd_to_page(git_cmd);\n \tsetenv(\"INFOPATH\", system_path(GIT_INFO_PATH), 1);\n \texeclp(\"info\", \"info\", \"gitman\", page, (char *)NULL);\n-\tdie(\"no info viewer handled the request\");\n+\tdie(_(\"no info viewer handled the request\"));\n }\n \n static void get_html_page_path(struct strbuf *page_path, const char *page)\n@@ -384,7 +384,7 @@ static void get_html_page_path(struct strbuf *page_path, const char *page)\n \t/* Check that we have a git documentation directory. */\n \tif (stat(mkpath(\"%s/git.html\", html_path), &st)\n \t    || !S_ISREG(st.st_mode))\n-\t\tdie(\"'%s': not a documentation directory.\", html_path);\n+\t\tdie(_(\"'%s': not a documentation directory.\"), html_path);\n \n \tstrbuf_init(page_path, 0);\n \tstrbuf_addf(page_path, \"%s/%s.html\", html_path, page);\n@@ -424,16 +424,16 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \tparsed_help_format = help_format;\n \n \tif (show_all) {\n-\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n-\t\tlist_commands(\"git commands\", &main_cmds, &other_cmds);\n-\t\tprintf(\"%s\\n\", git_more_info_string);\n+\t\tprintf(_(\"usage: %s%s\"), _(git_usage_string), \"\\n\\n\");\n+\t\tlist_commands(_(\"git commands\"), &main_cmds, &other_cmds);\n+\t\tprintf(\"%s\\n\", _(git_more_info_string));\n \t\treturn 0;\n \t}\n \n \tif (!argv[0]) {\n-\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n+\t\tprintf(_(\"usage: %s%s\"), _(git_usage_string), \"\\n\\n\");\n \t\tlist_common_cmds_help();\n-\t\tprintf(\"\\n%s\\n\", git_more_info_string);\n+\t\tprintf(\"\\n%s\\n\", _(git_more_info_string));\n \t\treturn 0;\n \t}\n \n@@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \n \talias = alias_lookup(argv[0]);\n \tif (alias && !is_git_command(argv[0])) {\n-\t\tprintf(\"`git %s' is aliased to `%s'\\n\", argv[0], alias);\n+\t\tprintf_ln(_(\"`git %s' is aliased to `%s'\"), argv[0], alias);\n \t\treturn 0;\n \t}\n \ndiff --git a/generate-cmdlist.sh b/generate-cmdlist.sh\nindex 1093ef4..9a4c9b9 100755\n--- a/generate-cmdlist.sh\n+++ b/generate-cmdlist.sh\n@@ -16,7 +16,7 @@ do\n      /^NAME/,/git-'\"$cmd\"'/H\n      ${\n \t    x\n-\t    s/.*git-'\"$cmd\"' - \\(.*\\)/  {\"'\"$cmd\"'\", \"\\1\"},/\n+\t    s/.*git-'\"$cmd\"' - \\(.*\\)/  {\"'\"$cmd\"'\", N_(\"\\1\")},/\n \t    p\n      }' \"Documentation/git-$cmd.txt\"\n done\ndiff --git a/git.c b/git.c\nindex 3805616..4486deb 100644\n--- a/git.c\n+++ b/git.c\n@@ -13,7 +13,7 @@ const char git_usage_string[] =\n \t\"           <command> [<args>]\";\n \n const char git_more_info_string[] =\n-\t\"See 'git help <command>' for more information on a specific command.\";\n+\tN_(\"See 'git help <command>' for more information on a specific command.\");\n \n static struct startup_info git_startup_info;\n static int use_pager = -1;\ndiff --git a/help.c b/help.c\nindex 14eefc9..462e83b 100644\n--- a/help.c\n+++ b/help.c\n@@ -217,8 +217,9 @@ void list_commands(const char *title, struct cmdnames *main_cmds,\n \n \tif (main_cmds->cnt) {\n \t\tconst char *exec_path = git_exec_path();\n-\t\tprintf(\"available %s in '%s'\\n\", title, exec_path);\n-\t\tprintf(\"----------------\");\n+\t\tprintf_ln(_(\"available %s in '%s'\"), title, exec_path);\n+\t\t/* TRANSLATORS: this must align with \"available %s in '%s'\" */\n+\t\tprintf(_(\"----------------\"));\n \t\tmput_char('-', strlen(title) + strlen(exec_path));\n \t\tputchar('\\n');\n \t\tpretty_print_string_list(main_cmds, longest);\n@@ -226,8 +227,12 @@ void list_commands(const char *title, struct cmdnames *main_cmds,\n \t}\n \n \tif (other_cmds->cnt) {\n-\t\tprintf(\"%s available from elsewhere on your $PATH\\n\", title);\n-\t\tprintf(\"---------------------------------------\");\n+\t\tprintf_ln(_(\"%s available from elsewhere on your $PATH\"), title);\n+\t\t/* TRANSLATORS:\n+\t\t * this must align with\n+\t\t * \"%s available from elsewhere on your $PATH\"\n+\t\t */\n+\t\tprintf(_(\"---------------------------------------\"));\n \t\tmput_char('-', strlen(title));\n \t\tputchar('\\n');\n \t\tpretty_print_string_list(other_cmds, longest);\n@@ -341,7 +346,7 @@ const char *help_unknown_cmd(const char *cmd)\n \t      sizeof(*main_cmds.names), levenshtein_compare);\n \n \tif (!main_cmds.cnt)\n-\t\tdie (\"Uh oh. Your system reports no Git commands at all.\");\n+\t\tdie(_(\"Uh oh. Your system reports no Git commands at all.\"));\n \n \t/* skip and count prefix matches */\n \tfor (n = 0; n < main_cmds.cnt && !main_cmds.names[n]->len; n++)\n@@ -362,23 +367,26 @@ const char *help_unknown_cmd(const char *cmd)\n \t\tconst char *assumed = main_cmds.names[0]->name;\n \t\tmain_cmds.names[0] = NULL;\n \t\tclean_cmdnames(&main_cmds);\n-\t\tfprintf(stderr, \"WARNING: You called a Git command named '%s', \"\n-\t\t\t\"which does not exist.\\n\"\n-\t\t\t\"Continuing under the assumption that you meant '%s'\\n\",\n+\t\tfprintf_ln(stderr,\n+\t\t\t   _(\"WARNING: You called a Git command named '%s', \"\n+\t\t\t     \"which does not exist.\\n\"\n+\t\t\t     \"Continuing under the assumption that you meant '%s'\"),\n \t\t\tcmd, assumed);\n \t\tif (autocorrect > 0) {\n-\t\t\tfprintf(stderr, \"in %0.1f seconds automatically...\\n\",\n+\t\t\tfprintf_ln(stderr, _(\"in %0.1f seconds automatically...\"),\n \t\t\t\t(float)autocorrect/10.0);\n \t\t\tpoll(NULL, 0, autocorrect * 100);\n \t\t}\n \t\treturn assumed;\n \t}\n \n-\tfprintf(stderr, \"git: '%s' is not a git command. See 'git --help'.\\n\", cmd);\n+\tfprintf_ln(stderr, _(\"git: '%s' is not a git command. See 'git --help'.\"), cmd);\n \n \tif (SIMILAR_ENOUGH(best_similarity)) {\n-\t\tfprintf(stderr, \"\\nDid you mean %s?\\n\",\n-\t\t\tn < 2 ? \"this\": \"one of these\");\n+\t\tfprintf_ln(stderr,\n+\t\t\t   Q_(\"\\nDid you mean this?\",\n+\t\t\t      \"\\nDid you mean one of these?\",\n+\t\t\t   n));\n \n \t\tfor (i = 0; i < n; i++)\n \t\t\tfprintf(stderr, \"\\t%s\\n\", main_cmds.names[i]->name);\n@@ -389,6 +397,6 @@ const char *help_unknown_cmd(const char *cmd)\n \n int cmd_version(int argc, const char **argv, const char *prefix)\n {\n-\tprintf(\"git version %s\\n\", git_version_string);\n+\tprintf_ln(_(\"git version %s\"), git_version_string);\n \treturn 0;\n }\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189398","messageId":"1334580603-11577-7-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 06/11] i18n: make warn_dangling_symref() automatically append \\n","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:58Z","receivedAt":"2012-04-16T12:49:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This helps remove \\n from translatable strings\n---\n builtin/fetch.c  |    4 ++--\n builtin/remote.c |    4 ++--\n refs.c           |    1 +\n 3 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 65f5f9b..a8c3e4c 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -537,8 +537,8 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)\n \tint result = 0;\n \tstruct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);\n \tconst char *dangling_msg = dry_run\n-\t\t? _(\"   (%s will become dangling)\\n\")\n-\t\t: _(\"   (%s has become dangling)\\n\");\n+\t\t? _(\"   (%s will become dangling)\")\n+\t\t: _(\"   (%s has become dangling)\");\n \n \tfor (ref = stale_refs; ref; ref = ref->next) {\n \t\tif (!dry_run)\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex fec92bc..1b03473 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1260,8 +1260,8 @@ static int prune_remote(const char *remote, int dry_run)\n \tint result = 0, i;\n \tstruct ref_states states;\n \tconst char *dangling_msg = dry_run\n-\t\t? \" %s will become dangling!\\n\"\n-\t\t: \" %s has become dangling!\\n\";\n+\t\t? \" %s will become dangling!\"\n+\t\t: \" %s has become dangling!\";\n \n \tmemset(&states, 0, sizeof(states));\n \tget_remote_ref_states(remote, &states, GET_REF_STATES);\ndiff --git a/refs.c b/refs.c\nindex c9f6835..54b2a03 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -395,6 +395,7 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha\n \t\treturn 0;\n \n \tfprintf(d->fp, d->msg_fmt, refname);\n+\tfprintf(d->fp, \"\\n\");\n \treturn 0;\n }\n \n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189399","messageId":"1334580603-11577-8-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 07/11] i18n: remote: mark strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:49:59Z","receivedAt":"2012-04-16T12:49:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n builtin/remote.c |  252 ++++++++++++++++++++++++++++-------------------------\n 1 files changed, 133 insertions(+), 119 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 1b03473..db28750 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -8,18 +8,18 @@\n #include \"refs.h\"\n \n static const char * const builtin_remote_usage[] = {\n-\t\"git remote [-v | --verbose]\",\n-\t\"git remote add [-t <branch>] [-m <master>] [-f] [--mirror=<fetch|push>] <name> <url>\",\n-\t\"git remote rename <old> <new>\",\n-\t\"git remote rm <name>\",\n-\t\"git remote set-head <name> (-a | -d | <branch>)\",\n-\t\"git remote [-v | --verbose] show [-n] <name>\",\n-\t\"git remote prune [-n | --dry-run] <name>\",\n-\t\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\",\n-\t\"git remote set-branches [--add] <name> <branch>...\",\n-\t\"git remote set-url <name> <newurl> [<oldurl>]\",\n-\t\"git remote set-url --add <name> <newurl>\",\n-\t\"git remote set-url --delete <name> <url>\",\n+\tN_(\"git remote [-v | --verbose]\"),\n+\tN_(\"git remote add [-t <branch>] [-m <master>] [-f] [--mirror=<fetch|push>] <name> <url>\"),\n+\tN_(\"git remote rename <old> <new>\"),\n+\tN_(\"git remote rm <name>\"),\n+\tN_(\"git remote set-head <name> (-a | -d | <branch>)\"),\n+\tN_(\"git remote [-v | --verbose] show [-n] <name>\"),\n+\tN_(\"git remote prune [-n | --dry-run] <name>\"),\n+\tN_(\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\"),\n+\tN_(\"git remote set-branches [--add] <name> <branch>...\"),\n+\tN_(\"git remote set-url <name> <newurl> [<oldurl>]\"),\n+\tN_(\"git remote set-url --add <name> <newurl>\"),\n+\tN_(\"git remote set-url --delete <name> <url>\"),\n \tNULL\n };\n \n@@ -95,9 +95,9 @@ static int fetch_remote(const char *name)\n \t\targv[1] = \"-v\";\n \t\targv[2] = name;\n \t}\n-\tprintf(\"Updating %s\\n\", name);\n+\tprintf_ln(_(\"Updating %s\"), name);\n \tif (run_command_v_opt(argv, RUN_GIT_CMD))\n-\t\treturn error(\"Could not fetch %s\", name);\n+\t\treturn error(_(\"Could not fetch %s\"), name);\n \treturn 0;\n }\n \n@@ -127,8 +127,8 @@ static int add_branch(const char *key, const char *branchname,\n }\n \n static const char mirror_advice[] =\n-\"--mirror is dangerous and deprecated; please\\n\"\n-\"\\t use --mirror=fetch or --mirror=push instead\";\n+N_(\"--mirror is dangerous and deprecated; please\\n\"\n+   \"\\t use --mirror=fetch or --mirror=push instead\");\n \n static int parse_mirror_opt(const struct option *opt, const char *arg, int not)\n {\n@@ -136,7 +136,7 @@ static int parse_mirror_opt(const struct option *opt, const char *arg, int not)\n \tif (not)\n \t\t*mirror = MIRROR_NONE;\n \telse if (!arg) {\n-\t\twarning(\"%s\", mirror_advice);\n+\t\twarning(\"%s\", _(mirror_advice));\n \t\t*mirror = MIRROR_BOTH;\n \t}\n \telse if (!strcmp(arg, \"fetch\"))\n@@ -144,7 +144,7 @@ static int parse_mirror_opt(const struct option *opt, const char *arg, int not)\n \telse if (!strcmp(arg, \"push\"))\n \t\t*mirror = MIRROR_PUSH;\n \telse\n-\t\treturn error(\"unknown mirror argument: %s\", arg);\n+\t\treturn error(_(\"unknown mirror argument: %s\"), arg);\n \treturn 0;\n }\n \n@@ -182,9 +182,9 @@ static int add(int argc, const char **argv)\n \t\tusage_with_options(builtin_remote_add_usage, options);\n \n \tif (mirror && master)\n-\t\tdie(\"specifying a master branch makes no sense with --mirror\");\n+\t\tdie(_(\"specifying a master branch makes no sense with --mirror\"));\n \tif (mirror && !(mirror & MIRROR_FETCH) && track.nr)\n-\t\tdie(\"specifying branches to track makes sense only with fetch mirrors\");\n+\t\tdie(_(\"specifying branches to track makes sense only with fetch mirrors\"));\n \n \tname = argv[0];\n \turl = argv[1];\n@@ -192,11 +192,11 @@ static int add(int argc, const char **argv)\n \tremote = remote_get(name);\n \tif (remote && (remote->url_nr > 1 || strcmp(name, remote->url[0]) ||\n \t\t\tremote->fetch_refspec_nr))\n-\t\tdie(\"remote %s already exists.\", name);\n+\t\tdie(_(\"remote %s already exists.\"), name);\n \n \tstrbuf_addf(&buf2, \"refs/heads/test:refs/remotes/%s/test\", name);\n \tif (!valid_fetch_refspec(buf2.buf))\n-\t\tdie(\"'%s' is not a valid remote name\", name);\n+\t\tdie(_(\"'%s' is not a valid remote name\"), name);\n \n \tstrbuf_addf(&buf, \"remote.%s.url\", name);\n \tif (git_config_set(buf.buf, url))\n@@ -240,7 +240,7 @@ static int add(int argc, const char **argv)\n \t\tstrbuf_addf(&buf2, \"refs/remotes/%s/%s\", name, master);\n \n \t\tif (create_symref(buf.buf, buf2.buf, \"remote add\"))\n-\t\t\treturn error(\"Could not setup master '%s'\", master);\n+\t\t\treturn error(_(\"Could not setup master '%s'\"), master);\n \t}\n \n \tstrbuf_release(&buf);\n@@ -296,7 +296,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)\n \t\tinfo = item->util;\n \t\tif (type == REMOTE) {\n \t\t\tif (info->remote_name)\n-\t\t\t\twarning(\"more than one %s\", orig_key);\n+\t\t\t\twarning(_(\"more than one %s\"), orig_key);\n \t\t\tinfo->remote_name = xstrdup(value);\n \t\t} else if (type == MERGE) {\n \t\t\tchar *space = strchr(value, ' ');\n@@ -336,7 +336,7 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat\n \n \tfor (i = 0; i < states->remote->fetch_refspec_nr; i++)\n \t\tif (get_fetch_map(remote_refs, states->remote->fetch + i, &tail, 1))\n-\t\t\tdie(\"Could not get fetch map for refspec %s\",\n+\t\t\tdie(_(\"Could not get fetch map for refspec %s\"),\n \t\t\t\tstates->remote->fetch_refspec[i]);\n \n \tstates->new.strdup_strings = 1;\n@@ -437,7 +437,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)\n \n \tstates->push.strdup_strings = 1;\n \tif (!remote->push_refspec_nr) {\n-\t\titem = string_list_append(&states->push, \"(matching)\");\n+\t\titem = string_list_append(&states->push, _(\"(matching)\"));\n \t\tinfo = item->util = xcalloc(sizeof(struct push_info), 1);\n \t\tinfo->status = PUSH_STATUS_NOTQUERIED;\n \t\tinfo->dest = xstrdup(item->string);\n@@ -445,11 +445,11 @@ static int get_push_ref_states_noquery(struct ref_states *states)\n \tfor (i = 0; i < remote->push_refspec_nr; i++) {\n \t\tstruct refspec *spec = remote->push + i;\n \t\tif (spec->matching)\n-\t\t\titem = string_list_append(&states->push, \"(matching)\");\n+\t\t\titem = string_list_append(&states->push, _(\"(matching)\"));\n \t\telse if (strlen(spec->src))\n \t\t\titem = string_list_append(&states->push, spec->src);\n \t\telse\n-\t\t\titem = string_list_append(&states->push, \"(delete)\");\n+\t\t\titem = string_list_append(&states->push, _(\"(delete)\"));\n \n \t\tinfo = item->util = xcalloc(sizeof(struct push_info), 1);\n \t\tinfo->forced = spec->force;\n@@ -592,19 +592,19 @@ static int migrate_file(struct remote *remote)\n \tstrbuf_addf(&buf, \"remote.%s.url\", remote->name);\n \tfor (i = 0; i < remote->url_nr; i++)\n \t\tif (git_config_set_multivar(buf.buf, remote->url[i], \"^$\", 0))\n-\t\t\treturn error(\"Could not append '%s' to '%s'\",\n+\t\t\treturn error(_(\"Could not append '%s' to '%s'\"),\n \t\t\t\t\tremote->url[i], buf.buf);\n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.push\", remote->name);\n \tfor (i = 0; i < remote->push_refspec_nr; i++)\n \t\tif (git_config_set_multivar(buf.buf, remote->push_refspec[i], \"^$\", 0))\n-\t\t\treturn error(\"Could not append '%s' to '%s'\",\n+\t\t\treturn error(_(\"Could not append '%s' to '%s'\"),\n \t\t\t\t\tremote->push_refspec[i], buf.buf);\n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.fetch\", remote->name);\n \tfor (i = 0; i < remote->fetch_refspec_nr; i++)\n \t\tif (git_config_set_multivar(buf.buf, remote->fetch_refspec[i], \"^$\", 0))\n-\t\t\treturn error(\"Could not append '%s' to '%s'\",\n+\t\t\treturn error(_(\"Could not append '%s' to '%s'\"),\n \t\t\t\t\tremote->fetch_refspec[i], buf.buf);\n \tif (remote->origin == REMOTE_REMOTES)\n \t\tpath = git_path(\"remotes/%s\", remote->name);\n@@ -636,30 +636,30 @@ static int mv(int argc, const char **argv)\n \n \toldremote = remote_get(rename.old);\n \tif (!oldremote)\n-\t\tdie(\"No such remote: %s\", rename.old);\n+\t\tdie(_(\"No such remote: %s\"), rename.old);\n \n \tif (!strcmp(rename.old, rename.new) && oldremote->origin != REMOTE_CONFIG)\n \t\treturn migrate_file(oldremote);\n \n \tnewremote = remote_get(rename.new);\n \tif (newremote && (newremote->url_nr > 1 || newremote->fetch_refspec_nr))\n-\t\tdie(\"remote %s already exists.\", rename.new);\n+\t\tdie(_(\"remote %s already exists.\"), rename.new);\n \n \tstrbuf_addf(&buf, \"refs/heads/test:refs/remotes/%s/test\", rename.new);\n \tif (!valid_fetch_refspec(buf.buf))\n-\t\tdie(\"'%s' is not a valid remote name\", rename.new);\n+\t\tdie(_(\"'%s' is not a valid remote name\"), rename.new);\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s\", rename.old);\n \tstrbuf_addf(&buf2, \"remote.%s\", rename.new);\n \tif (git_config_rename_section(buf.buf, buf2.buf) < 1)\n-\t\treturn error(\"Could not rename config section '%s' to '%s'\",\n+\t\treturn error(_(\"Could not rename config section '%s' to '%s'\"),\n \t\t\t\tbuf.buf, buf2.buf);\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.fetch\", rename.new);\n \tif (git_config_set_multivar(buf.buf, NULL, NULL, 1))\n-\t\treturn error(\"Could not remove config section '%s'\", buf.buf);\n+\t\treturn error(_(\"Could not remove config section '%s'\"), buf.buf);\n \tstrbuf_addf(&old_remote_context, \":refs/remotes/%s/\", rename.old);\n \tfor (i = 0; i < oldremote->fetch_refspec_nr; i++) {\n \t\tchar *ptr;\n@@ -674,13 +674,13 @@ static int mv(int argc, const char **argv)\n \t\t\t\t      strlen(rename.old), rename.new,\n \t\t\t\t      strlen(rename.new));\n \t\t} else\n-\t\t\twarning(\"Not updating non-default fetch respec\\n\"\n-\t\t\t\t\"\\t%s\\n\"\n-\t\t\t\t\"\\tPlease update the configuration manually if necessary.\",\n+\t\t\twarning(_(\"Not updating non-default fetch respec\\n\"\n+\t\t\t\t  \"\\t%s\\n\"\n+\t\t\t\t  \"\\tPlease update the configuration manually if necessary.\"),\n \t\t\t\tbuf2.buf);\n \n \t\tif (git_config_set_multivar(buf.buf, buf2.buf, \"^$\", 0))\n-\t\t\treturn error(\"Could not append '%s'\", buf.buf);\n+\t\t\treturn error(_(\"Could not append '%s'\"), buf.buf);\n \t}\n \n \tread_branches();\n@@ -691,7 +691,7 @@ static int mv(int argc, const char **argv)\n \t\t\tstrbuf_reset(&buf);\n \t\t\tstrbuf_addf(&buf, \"branch.%s.remote\", item->string);\n \t\t\tif (git_config_set(buf.buf, rename.new)) {\n-\t\t\t\treturn error(\"Could not set '%s'\", buf.buf);\n+\t\t\t\treturn error(_(\"Could not set '%s'\"), buf.buf);\n \t\t\t}\n \t\t}\n \t}\n@@ -713,7 +713,7 @@ static int mv(int argc, const char **argv)\n \t\tif (!(flag & REF_ISSYMREF))\n \t\t\tcontinue;\n \t\tif (delete_ref(item->string, NULL, REF_NODEREF))\n-\t\t\tdie(\"deleting '%s' failed\", item->string);\n+\t\t\tdie(_(\"deleting '%s' failed\"), item->string);\n \t}\n \tfor (i = 0; i < remote_branches.nr; i++) {\n \t\tstruct string_list_item *item = remote_branches.items + i;\n@@ -728,7 +728,7 @@ static int mv(int argc, const char **argv)\n \t\tstrbuf_addf(&buf2, \"remote: renamed %s to %s\",\n \t\t\t\titem->string, buf.buf);\n \t\tif (rename_ref(item->string, buf.buf, buf2.buf))\n-\t\t\tdie(\"renaming '%s' failed\", item->string);\n+\t\t\tdie(_(\"renaming '%s' failed\"), item->string);\n \t}\n \tfor (i = 0; i < remote_branches.nr; i++) {\n \t\tstruct string_list_item *item = remote_branches.items + i;\n@@ -747,7 +747,7 @@ static int mv(int argc, const char **argv)\n \t\tstrbuf_addf(&buf3, \"remote: renamed %s to %s\",\n \t\t\t\titem->string, buf.buf);\n \t\tif (create_symref(buf.buf, buf2.buf, buf3.buf))\n-\t\t\tdie(\"creating '%s' failed\", buf.buf);\n+\t\t\tdie(_(\"creating '%s' failed\"), buf.buf);\n \t}\n \treturn 0;\n }\n@@ -761,7 +761,7 @@ static int remove_branches(struct string_list *branches)\n \t\tunsigned char *sha1 = item->util;\n \n \t\tif (delete_ref(refname, sha1, 0))\n-\t\t\tresult |= error(\"Could not remove branch %s\", refname);\n+\t\t\tresult |= error(_(\"Could not remove branch %s\"), refname);\n \t}\n \treturn result;\n }\n@@ -789,14 +789,14 @@ static int rm(int argc, const char **argv)\n \n \tremote = remote_get(argv[1]);\n \tif (!remote)\n-\t\tdie(\"No such remote: %s\", argv[1]);\n+\t\tdie(_(\"No such remote: %s\"), argv[1]);\n \n \tknown_remotes.to_delete = remote;\n \tfor_each_remote(add_known_remote, &known_remotes);\n \n \tstrbuf_addf(&buf, \"remote.%s\", remote->name);\n \tif (git_config_rename_section(buf.buf, NULL) < 1)\n-\t\treturn error(\"Could not remove config section '%s'\", buf.buf);\n+\t\treturn error(_(\"Could not remove config section '%s'\"), buf.buf);\n \n \tread_branches();\n \tfor (i = 0; i < branch_list.nr; i++) {\n@@ -830,11 +830,11 @@ static int rm(int argc, const char **argv)\n \tstring_list_clear(&branches, 1);\n \n \tif (skipped.nr) {\n-\t\tfprintf(stderr, skipped.nr == 1 ?\n-\t\t\t\"Note: A branch outside the refs/remotes/ hierarchy was not removed;\\n\"\n-\t\t\t\"to delete it, use:\\n\" :\n-\t\t\t\"Note: Some branches outside the refs/remotes/ hierarchy were not removed;\\n\"\n-\t\t\t\"to delete them, use:\\n\");\n+\t\tfprintf_ln(stderr, skipped.nr == 1 ?\n+\t\t\t   _(\"Note: A branch outside the refs/remotes/ hierarchy was not removed;\\n\"\n+\t\t\t     \"to delete it, use:\") :\n+\t\t\t   _(\"Note: Some branches outside the refs/remotes/ hierarchy were not removed;\\n\"\n+\t\t\t     \"to delete them, use:\"));\n \t\tfor (i = 0; i < skipped.nr; i++)\n \t\t\tfprintf(stderr, \"  git branch -d %s\\n\",\n \t\t\t\tskipped.items[i].string);\n@@ -886,7 +886,7 @@ static int get_remote_ref_states(const char *name,\n \n \tstates->remote = remote_get(name);\n \tif (!states->remote)\n-\t\treturn error(\"No such remote: %s\", name);\n+\t\treturn error(_(\"No such remote: %s\"), name);\n \n \tread_branches();\n \n@@ -939,14 +939,14 @@ static int show_remote_info_item(struct string_list_item *item, void *cb_data)\n \t\tconst char *fmt = \"%s\";\n \t\tconst char *arg = \"\";\n \t\tif (string_list_has_string(&states->new, name)) {\n-\t\t\tfmt = \" new (next fetch will store in remotes/%s)\";\n+\t\t\tfmt = _(\" new (next fetch will store in remotes/%s)\");\n \t\t\targ = states->remote->name;\n \t\t} else if (string_list_has_string(&states->tracked, name))\n-\t\t\targ = \" tracked\";\n+\t\t\targ = _(\" tracked\");\n \t\telse if (string_list_has_string(&states->stale, name))\n-\t\t\targ = \" stale (use 'git remote prune' to remove)\";\n+\t\t\targ = _(\" stale (use 'git remote prune' to remove)\");\n \t\telse\n-\t\t\targ = \" ???\";\n+\t\t\targ = _(\" ???\");\n \t\tprintf(\"    %-*s\", info->width, name);\n \t\tprintf(fmt, arg);\n \t\tprintf(\"\\n\");\n@@ -987,21 +987,21 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)\n \tint i;\n \n \tif (branch_info->rebase && branch_info->merge.nr > 1) {\n-\t\terror(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\",\n+\t\terror(_(\"invalid branch.%s.merge; cannot rebase onto > 1 branch\"),\n \t\t\titem->string);\n \t\treturn 0;\n \t}\n \n \tprintf(\"    %-*s \", show_info->width, item->string);\n \tif (branch_info->rebase) {\n-\t\tprintf(\"rebases onto remote %s\\n\", merge->items[0].string);\n+\t\tprintf_ln(_(\"rebases onto remote %s\"), merge->items[0].string);\n \t\treturn 0;\n \t} else if (show_info->any_rebase) {\n-\t\tprintf(\" merges with remote %s\\n\", merge->items[0].string);\n-\t\talso = \"    and with remote\";\n+\t\tprintf_ln(_(\" merges with remote %s\"), merge->items[0].string);\n+\t\talso = _(\"    and with remote\");\n \t} else {\n-\t\tprintf(\"merges with remote %s\\n\", merge->items[0].string);\n-\t\talso = \"   and with remote\";\n+\t\tprintf_ln(_(\"merges with remote %s\"), merge->items[0].string);\n+\t\talso = _(\"   and with remote\");\n \t}\n \tfor (i = 1; i < merge->nr; i++)\n \t\tprintf(\"    %-*s %s %s\\n\", show_info->width, \"\", also,\n@@ -1043,36 +1043,43 @@ static int show_push_info_item(struct string_list_item *item, void *cb_data)\n {\n \tstruct show_info *show_info = cb_data;\n \tstruct push_info *push_info = item->util;\n-\tchar *src = item->string, *status = NULL;\n+\tconst char *src = item->string, *status = NULL;\n \n \tswitch (push_info->status) {\n \tcase PUSH_STATUS_CREATE:\n-\t\tstatus = \"create\";\n+\t\tstatus = _(\"create\");\n \t\tbreak;\n \tcase PUSH_STATUS_DELETE:\n-\t\tstatus = \"delete\";\n-\t\tsrc = \"(none)\";\n+\t\tstatus = _(\"delete\");\n+\t\tsrc = _(\"(none)\");\n \t\tbreak;\n \tcase PUSH_STATUS_UPTODATE:\n-\t\tstatus = \"up to date\";\n+\t\tstatus = _(\"up to date\");\n \t\tbreak;\n \tcase PUSH_STATUS_FASTFORWARD:\n-\t\tstatus = \"fast-forwardable\";\n+\t\tstatus = _(\"fast-forwardable\");\n \t\tbreak;\n \tcase PUSH_STATUS_OUTOFDATE:\n-\t\tstatus = \"local out of date\";\n+\t\tstatus = _(\"local out of date\");\n \t\tbreak;\n \tcase PUSH_STATUS_NOTQUERIED:\n \t\tbreak;\n \t}\n-\tif (status)\n-\t\tprintf(\"    %-*s %s to %-*s (%s)\\n\", show_info->width, src,\n-\t\t\tpush_info->forced ? \"forces\" : \"pushes\",\n-\t\t\tshow_info->width2, push_info->dest, status);\n-\telse\n-\t\tprintf(\"    %-*s %s to %s\\n\", show_info->width, src,\n-\t\t\tpush_info->forced ? \"forces\" : \"pushes\",\n-\t\t\tpush_info->dest);\n+\tif (status) {\n+\t\tif (push_info->forced)\n+\t\t\tprintf_ln(_(\"    %-*s forces to %-*s (%s)\"), show_info->width, src,\n+\t\t\t       show_info->width2, push_info->dest, status);\n+\t\telse\n+\t\t\tprintf_ln(_(\"    %-*s pushes to %-*s (%s)\"), show_info->width, src,\n+\t\t\t       show_info->width2, push_info->dest, status);\n+\t} else {\n+\t\tif (push_info->forced)\n+\t\t\tprintf_ln(_(\"    %-*s forces to %s\"), show_info->width, src,\n+\t\t\t       push_info->dest);\n+\t\telse\n+\t\t\tprintf_ln(_(\"    %-*s pushes to %s\"), show_info->width, src,\n+\t\t\t       push_info->dest);\n+\t}\n \treturn 0;\n }\n \n@@ -1107,9 +1114,9 @@ static int show(int argc, const char **argv)\n \n \t\tget_remote_ref_states(*argv, &states, query_flag);\n \n-\t\tprintf(\"* remote %s\\n\", *argv);\n-\t\tprintf(\"  Fetch URL: %s\\n\", states.remote->url_nr > 0 ?\n-\t\t\tstates.remote->url[0] : \"(no URL)\");\n+\t\tprintf_ln(_(\"* remote %s\"), *argv);\n+\t\tprintf_ln(_(\"  Fetch URL: %s\"), states.remote->url_nr > 0 ?\n+\t\t       states.remote->url[0] : _(\"(no URL)\"));\n \t\tif (states.remote->pushurl_nr) {\n \t\t\turl = states.remote->pushurl;\n \t\t\turl_nr = states.remote->pushurl_nr;\n@@ -1118,18 +1125,18 @@ static int show(int argc, const char **argv)\n \t\t\turl_nr = states.remote->url_nr;\n \t\t}\n \t\tfor (i = 0; i < url_nr; i++)\n-\t\t\tprintf(\"  Push  URL: %s\\n\", url[i]);\n+\t\t\tprintf_ln(_(\"  Push  URL: %s\"), url[i]);\n \t\tif (!i)\n-\t\t\tprintf(\"  Push  URL: %s\\n\", \"(no URL)\");\n+\t\t\tprintf_ln(_(\"  Push  URL: %s\"), \"(no URL)\");\n \t\tif (no_query)\n-\t\t\tprintf(\"  HEAD branch: (not queried)\\n\");\n+\t\t\tprintf_ln(_(\"  HEAD branch: %s\"), \"(not queried)\");\n \t\telse if (!states.heads.nr)\n-\t\t\tprintf(\"  HEAD branch: (unknown)\\n\");\n+\t\t\tprintf_ln(_(\"  HEAD branch: %s\"), \"(unknown)\");\n \t\telse if (states.heads.nr == 1)\n-\t\t\tprintf(\"  HEAD branch: %s\\n\", states.heads.items[0].string);\n+\t\t\tprintf_ln(_(\"  HEAD branch: %s\"), states.heads.items[0].string);\n \t\telse {\n-\t\t\tprintf(\"  HEAD branch (remote HEAD is ambiguous,\"\n-\t\t\t       \" may be one of the following):\\n\");\n+\t\t\tprintf(_(\"  HEAD branch (remote HEAD is ambiguous,\"\n+\t\t\t\t \" may be one of the following):\\n\"));\n \t\t\tfor (i = 0; i < states.heads.nr; i++)\n \t\t\t\tprintf(\"    %s\\n\", states.heads.items[i].string);\n \t\t}\n@@ -1140,9 +1147,10 @@ static int show(int argc, const char **argv)\n \t\tfor_each_string_list(&states.tracked, add_remote_to_show_info, &info);\n \t\tfor_each_string_list(&states.stale, add_remote_to_show_info, &info);\n \t\tif (info.list->nr)\n-\t\t\tprintf(\"  Remote branch%s:%s\\n\",\n-\t\t\t       info.list->nr > 1 ? \"es\" : \"\",\n-\t\t\t\tno_query ? \" (status not queried)\" : \"\");\n+\t\t\tprintf_ln(Q_(\"  Remote branch:%s\",\n+\t\t\t\t     \"  Remote branches:%s\",\n+\t\t\t\t     info.list->nr),\n+\t\t\t\t  no_query ? _(\" (status not queried)\") : \"\");\n \t\tfor_each_string_list(info.list, show_remote_info_item, &info);\n \t\tstring_list_clear(info.list, 0);\n \n@@ -1151,23 +1159,25 @@ static int show(int argc, const char **argv)\n \t\tinfo.any_rebase = 0;\n \t\tfor_each_string_list(&branch_list, add_local_to_show_info, &info);\n \t\tif (info.list->nr)\n-\t\t\tprintf(\"  Local branch%s configured for 'git pull':\\n\",\n-\t\t\t       info.list->nr > 1 ? \"es\" : \"\");\n+\t\t\tprintf_ln(Q_(\"  Local branch configured for 'git pull':\",\n+\t\t\t\t     \"  Local branches configured for 'git pull':\",\n+\t\t\t\t     info.list->nr));\n \t\tfor_each_string_list(info.list, show_local_info_item, &info);\n \t\tstring_list_clear(info.list, 0);\n \n \t\t/* git push info */\n \t\tif (states.remote->mirror)\n-\t\t\tprintf(\"  Local refs will be mirrored by 'git push'\\n\");\n+\t\t\tprintf_ln(_(\"  Local refs will be mirrored by 'git push'\"));\n \n \t\tinfo.width = info.width2 = 0;\n \t\tfor_each_string_list(&states.push, add_push_to_show_info, &info);\n \t\tqsort(info.list->items, info.list->nr,\n \t\t\tsizeof(*info.list->items), cmp_string_with_push);\n \t\tif (info.list->nr)\n-\t\t\tprintf(\"  Local ref%s configured for 'git push'%s:\\n\",\n-\t\t\t\tinfo.list->nr > 1 ? \"s\" : \"\",\n-\t\t\t\tno_query ? \" (status not queried)\" : \"\");\n+\t\t\tprintf_ln(Q_(\"  Local ref configured for 'git push'%s:\",\n+\t\t\t\t     \"  Local refs configured for 'git push'%s:\",\n+\t\t\t\t     info.list->nr),\n+\t\t\t\t  no_query ? _(\" (status not queried)\") : \"\");\n \t\tfor_each_string_list(info.list, show_push_info_item, &info);\n \t\tstring_list_clear(info.list, 0);\n \n@@ -1202,10 +1212,10 @@ static int set_head(int argc, const char **argv)\n \t\tmemset(&states, 0, sizeof(states));\n \t\tget_remote_ref_states(argv[0], &states, GET_HEAD_NAMES);\n \t\tif (!states.heads.nr)\n-\t\t\tresult |= error(\"Cannot determine remote HEAD\");\n+\t\t\tresult |= error(_(\"Cannot determine remote HEAD\"));\n \t\telse if (states.heads.nr > 1) {\n-\t\t\tresult |= error(\"Multiple remote HEAD branches. \"\n-\t\t\t\t\t\"Please choose one explicitly with:\");\n+\t\t\tresult |= error(_(\"Multiple remote HEAD branches. \"\n+\t\t\t\t\t  \"Please choose one explicitly with:\"));\n \t\t\tfor (i = 0; i < states.heads.nr; i++)\n \t\t\t\tfprintf(stderr, \"  git remote set-head %s %s\\n\",\n \t\t\t\t\targv[0], states.heads.items[i].string);\n@@ -1214,7 +1224,7 @@ static int set_head(int argc, const char **argv)\n \t\tfree_remote_ref_states(&states);\n \t} else if (opt_d && !opt_a && argc == 1) {\n \t\tif (delete_ref(buf.buf, NULL, REF_NODEREF))\n-\t\t\tresult |= error(\"Could not delete %s\", buf.buf);\n+\t\t\tresult |= error(_(\"Could not delete %s\"), buf.buf);\n \t} else\n \t\tusage_with_options(builtin_remote_sethead_usage, options);\n \n@@ -1222,9 +1232,9 @@ static int set_head(int argc, const char **argv)\n \t\tstrbuf_addf(&buf2, \"refs/remotes/%s/%s\", argv[0], head_name);\n \t\t/* make sure it's valid */\n \t\tif (!ref_exists(buf2.buf))\n-\t\t\tresult |= error(\"Not a valid ref: %s\", buf2.buf);\n+\t\t\tresult |= error(_(\"Not a valid ref: %s\"), buf2.buf);\n \t\telse if (create_symref(buf.buf, buf2.buf, \"remote set-head\"))\n-\t\t\tresult |= error(\"Could not setup %s\", buf.buf);\n+\t\t\tresult |= error(_(\"Could not setup %s\"), buf.buf);\n \t\tif (opt_a)\n \t\t\tprintf(\"%s/HEAD set to %s\\n\", argv[0], head_name);\n \t\tfree(head_name);\n@@ -1260,18 +1270,18 @@ static int prune_remote(const char *remote, int dry_run)\n \tint result = 0, i;\n \tstruct ref_states states;\n \tconst char *dangling_msg = dry_run\n-\t\t? \" %s will become dangling!\"\n-\t\t: \" %s has become dangling!\";\n+\t\t? _(\" %s will become dangling!\")\n+\t\t: _(\" %s has become dangling!\");\n \n \tmemset(&states, 0, sizeof(states));\n \tget_remote_ref_states(remote, &states, GET_REF_STATES);\n \n \tif (states.stale.nr) {\n-\t\tprintf(\"Pruning %s\\n\", remote);\n-\t\tprintf(\"URL: %s\\n\",\n+\t\tprintf_ln(_(\"Pruning %s\"), remote);\n+\t\tprintf_ln(_(\"URL: %s\"),\n \t\t       states.remote->url_nr\n \t\t       ? states.remote->url[0]\n-\t\t       : \"(no URL)\");\n+\t\t       : _(\"(no URL)\"));\n \t}\n \n \tfor (i = 0; i < states.stale.nr; i++) {\n@@ -1280,8 +1290,12 @@ static int prune_remote(const char *remote, int dry_run)\n \t\tif (!dry_run)\n \t\t\tresult |= delete_ref(refname, NULL, 0);\n \n-\t\tprintf(\" * [%s] %s\\n\", dry_run ? \"would prune\" : \"pruned\",\n-\t\t       abbrev_ref(refname, \"refs/remotes/\"));\n+\t\tif (dry_run)\n+\t\t\tprintf_ln(_(\" * [would prune] %s\"),\n+\t\t\t       abbrev_ref(refname, \"refs/remotes/\"));\n+\t\telse\n+\t\t\tprintf_ln(_(\" * [pruned] %s\"),\n+\t\t\t       abbrev_ref(refname, \"refs/remotes/\"));\n \t\twarn_dangling_symref(stdout, dangling_msg, refname);\n \t}\n \n@@ -1369,7 +1383,7 @@ static int set_remote_branches(const char *remotename, const char **branches,\n \tstrbuf_addf(&key, \"remote.%s.fetch\", remotename);\n \n \tif (!remote_is_configured(remotename))\n-\t\tdie(\"No such remote '%s'\", remotename);\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n \tremote = remote_get(remotename);\n \n \tif (!add_mode && remove_all_fetch_refspecs(remotename, key.buf)) {\n@@ -1396,7 +1410,7 @@ static int set_branches(int argc, const char **argv)\n \targc = parse_options(argc, argv, NULL, options,\n \t\t\t     builtin_remote_setbranches_usage, 0);\n \tif (argc == 0) {\n-\t\terror(\"no remote specified\");\n+\t\terror(_(\"no remote specified\"));\n \t\tusage_with_options(builtin_remote_setbranches_usage, options);\n \t}\n \targv[argc] = NULL;\n@@ -1429,7 +1443,7 @@ static int set_url(int argc, const char **argv)\n \t\t\t     PARSE_OPT_KEEP_ARGV0);\n \n \tif (add_mode && delete_mode)\n-\t\tdie(\"--add --delete doesn't make sense\");\n+\t\tdie(_(\"--add --delete doesn't make sense\"));\n \n \tif (argc < 3 || argc > 4 || ((add_mode || delete_mode) && argc != 3))\n \t\tusage_with_options(builtin_remote_seturl_usage, options);\n@@ -1443,7 +1457,7 @@ static int set_url(int argc, const char **argv)\n \t\toldurl = newurl;\n \n \tif (!remote_is_configured(remotename))\n-\t\tdie(\"No such remote '%s'\", remotename);\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n \tremote = remote_get(remotename);\n \n \tif (push_mode) {\n@@ -1469,7 +1483,7 @@ static int set_url(int argc, const char **argv)\n \n \t/* Old URL specified. Demand that one matches. */\n \tif (regcomp(&old_regex, oldurl, REG_EXTENDED))\n-\t\tdie(\"Invalid old URL pattern: %s\", oldurl);\n+\t\tdie(_(\"Invalid old URL pattern: %s\"), oldurl);\n \n \tfor (i = 0; i < urlset_nr; i++)\n \t\tif (!regexec(&old_regex, urlset[i], 0, NULL, 0))\n@@ -1477,9 +1491,9 @@ static int set_url(int argc, const char **argv)\n \t\telse\n \t\t\tnegative_matches++;\n \tif (!delete_mode && !matches)\n-\t\tdie(\"No such URL found: %s\", oldurl);\n+\t\tdie(_(\"No such URL found: %s\"), oldurl);\n \tif (delete_mode && !negative_matches && !push_mode)\n-\t\tdie(\"Will not delete all non-push URLs\");\n+\t\tdie(_(\"Will not delete all non-push URLs\"));\n \n \tregfree(&old_regex);\n \n@@ -1551,7 +1565,7 @@ static int show_all(void)\n int cmd_remote(int argc, const char **argv, const char *prefix)\n {\n \tstruct option options[] = {\n-\t\tOPT__VERBOSE(&verbose, \"be verbose; must be placed before a subcommand\"),\n+\t\tOPT__VERBOSE(&verbose, N_(\"be verbose; must be placed before a subcommand\")),\n \t\tOPT_END()\n \t};\n \tint result;\n@@ -1580,7 +1594,7 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \telse if (!strcmp(argv[0], \"update\"))\n \t\tresult = update(argc, argv);\n \telse {\n-\t\terror(\"Unknown subcommand: %s\", argv[0]);\n+\t\terror(_(\"Unknown subcommand: %s\"), argv[0]);\n \t\tusage_with_options(builtin_remote_usage, options);\n \t}\n \n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189400","messageId":"1334580603-11577-9-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 08/11] i18n: apply: mark strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:50:00Z","receivedAt":"2012-04-16T12:50:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n builtin/apply.c |  226 ++++++++++++++++++++++++++++---------------------------\n 1 files changed, 114 insertions(+), 112 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 389898f..6e9a02e 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -50,7 +50,7 @@ static const char *fake_ancestor;\n static int line_termination = '\\n';\n static unsigned int p_context = UINT_MAX;\n static const char * const apply_usage[] = {\n-\t\"git apply [options] [<patch>...]\",\n+\tN_(\"git apply [options] [<patch>...]\"),\n \tNULL\n };\n \n@@ -103,7 +103,7 @@ static void parse_whitespace_option(const char *option)\n \t\tws_error_action = correct_ws_error;\n \t\treturn;\n \t}\n-\tdie(\"unrecognized whitespace option '%s'\", option);\n+\tdie(_(\"unrecognized whitespace option '%s'\"), option);\n }\n \n static void parse_ignorewhitespace_option(const char *option)\n@@ -118,7 +118,7 @@ static void parse_ignorewhitespace_option(const char *option)\n \t\tws_ignore_action = ignore_ws_change;\n \t\treturn;\n \t}\n-\tdie(\"unrecognized whitespace ignore option '%s'\", option);\n+\tdie(_(\"unrecognized whitespace ignore option '%s'\"), option);\n }\n \n static void set_default_whitespace_mode(const char *whitespace_option)\n@@ -770,7 +770,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tif (!stamp) {\n \t\tstamp = xmalloc(sizeof(*stamp));\n \t\tif (regcomp(stamp, stamp_regexp, REG_EXTENDED)) {\n-\t\t\twarning(\"Cannot prepare timestamp regexp %s\",\n+\t\t\twarning(_(\"Cannot prepare timestamp regexp %s\"),\n \t\t\t\tstamp_regexp);\n \t\t\treturn 0;\n \t\t}\n@@ -779,7 +779,7 @@ static int has_epoch_timestamp(const char *nameline)\n \tstatus = regexec(stamp, timestamp, ARRAY_SIZE(m), m, 0);\n \tif (status) {\n \t\tif (status != REG_NOMATCH)\n-\t\t\twarning(\"regexec returned %d for input: %s\",\n+\t\t\twarning(_(\"regexec returned %d for input: %s\"),\n \t\t\t\tstatus, timestamp);\n \t\treturn 0;\n \t}\n@@ -857,7 +857,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc\n \t\t}\n \t}\n \tif (!name)\n-\t\tdie(\"unable to find filename in patch at line %d\", linenr);\n+\t\tdie(_(\"unable to find filename in patch at line %d\"), linenr);\n }\n \n static int gitdiff_hdrend(const char *line, struct patch *patch)\n@@ -886,17 +886,17 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,\n \t\tname = orig_name;\n \t\tlen = strlen(name);\n \t\tif (isnull)\n-\t\t\tdie(\"git apply: bad git-diff - expected /dev/null, got %s on line %d\", name, linenr);\n+\t\t\tdie(_(\"git apply: bad git-diff - expected /dev/null, got %s on line %d\"), name, linenr);\n \t\tanother = find_name(line, NULL, p_value, TERM_TAB);\n \t\tif (!another || memcmp(another, name, len + 1))\n-\t\t\tdie(\"git apply: bad git-diff - inconsistent %s filename on line %d\", oldnew, linenr);\n+\t\t\tdie(_(\"git apply: bad git-diff - inconsistent %s filename on line %d\"), oldnew, linenr);\n \t\tfree(another);\n \t\treturn orig_name;\n \t}\n \telse {\n \t\t/* expect \"/dev/null\" */\n \t\tif (memcmp(\"/dev/null\", line, 9) || line[9] != '\\n')\n-\t\t\tdie(\"git apply: bad git-diff - expected /dev/null on line %d\", linenr);\n+\t\t\tdie(_(\"git apply: bad git-diff - expected /dev/null on line %d\"), linenr);\n \t\treturn NULL;\n \t}\n }\n@@ -1327,7 +1327,7 @@ static void recount_diff(char *line, int size, struct fragment *fragment)\n \t\t\tbreak;\n \t\t}\n \t\tif (ret) {\n-\t\t\twarning(\"recount: unexpected line: %.*s\",\n+\t\t\twarning(_(\"recount: unexpected line: %.*s\"),\n \t\t\t\t(int)linelen(line, size), line);\n \t\t\treturn;\n \t\t}\n@@ -1384,7 +1384,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc\n \t\t\tstruct fragment dummy;\n \t\t\tif (parse_fragment_header(line, len, &dummy) < 0)\n \t\t\t\tcontinue;\n-\t\t\tdie(\"patch fragment without header at line %d: %.*s\",\n+\t\t\tdie(_(\"patch fragment without header at line %d: %.*s\"),\n \t\t\t    linenr, (int)len-1, line);\n \t\t}\n \n@@ -1556,9 +1556,9 @@ static int parse_fragment(char *line, unsigned long size,\n \tpatch->lines_deleted += deleted;\n \n \tif (0 < patch->is_new && oldlines)\n-\t\treturn error(\"new file depends on old contents\");\n+\t\treturn error(_(\"new file depends on old contents\"));\n \tif (0 < patch->is_delete && newlines)\n-\t\treturn error(\"deleted file still has contents\");\n+\t\treturn error(_(\"deleted file still has contents\"));\n \treturn offset;\n }\n \n@@ -1576,7 +1576,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc\n \t\tfragment->linenr = linenr;\n \t\tlen = parse_fragment(line, size, patch, fragment);\n \t\tif (len <= 0)\n-\t\t\tdie(\"corrupt patch at line %d\", linenr);\n+\t\t\tdie(_(\"corrupt patch at line %d\"), linenr);\n \t\tfragment->patch = line;\n \t\tfragment->size = len;\n \t\toldlines += fragment->oldlines;\n@@ -1612,12 +1612,14 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc\n \t\tpatch->is_delete = 0;\n \n \tif (0 < patch->is_new && oldlines)\n-\t\tdie(\"new file %s depends on old contents\", patch->new_name);\n+\t\tdie(_(\"new file %s depends on old contents\"), patch->new_name);\n \tif (0 < patch->is_delete && newlines)\n-\t\tdie(\"deleted file %s still has contents\", patch->old_name);\n+\t\tdie(_(\"deleted file %s still has contents\"), patch->old_name);\n \tif (!patch->is_delete && !newlines && context)\n-\t\tfprintf(stderr, \"** warning: file %s becomes empty but \"\n-\t\t\t\"is not deleted\\n\", patch->new_name);\n+\t\tfprintf_ln(stderr,\n+\t\t\t   _(\"** warning: \"\n+\t\t\t     \"file %s becomes empty but is not deleted\"),\n+\t\t\t   patch->new_name);\n \n \treturn offset;\n }\n@@ -1755,7 +1757,7 @@ static struct fragment *parse_binary_hunk(char **buf_p,\n  corrupt:\n \tfree(data);\n \t*status_p = -1;\n-\terror(\"corrupt binary patch at line %d: %.*s\",\n+\terror(_(\"corrupt binary patch at line %d: %.*s\"),\n \t      linenr-1, llen-1, buffer);\n \treturn NULL;\n }\n@@ -1784,7 +1786,7 @@ static int parse_binary(char *buffer, unsigned long size, struct patch *patch)\n \tforward = parse_binary_hunk(&buffer, &size, &status, &used);\n \tif (!forward && !status)\n \t\t/* there has to be one hunk (forward hunk) */\n-\t\treturn error(\"unrecognized binary patch at line %d\", linenr-1);\n+\t\treturn error(_(\"unrecognized binary patch at line %d\"), linenr-1);\n \tif (status)\n \t\t/* otherwise we already gave an error message */\n \t\treturn status;\n@@ -1863,7 +1865,7 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch)\n \t\t */\n \t\tif ((apply || check) &&\n \t\t    (!patch->is_binary && !metadata_changes(patch)))\n-\t\t\tdie(\"patch with only garbage at line %d\", linenr);\n+\t\t\tdie(_(\"patch with only garbage at line %d\"), linenr);\n \t}\n \n \treturn offset + hdrsize + patchsize;\n@@ -1953,11 +1955,11 @@ static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)\n \tswitch (st->st_mode & S_IFMT) {\n \tcase S_IFLNK:\n \t\tif (strbuf_readlink(buf, path, st->st_size) < 0)\n-\t\t\treturn error(\"unable to read symlink %s\", path);\n+\t\t\treturn error(_(\"unable to read symlink %s\"), path);\n \t\treturn 0;\n \tcase S_IFREG:\n \t\tif (strbuf_read_file(buf, path, st->st_size) != st->st_size)\n-\t\t\treturn error(\"unable to open or read %s\", path);\n+\t\t\treturn error(_(\"unable to open or read %s\"), path);\n \t\tconvert_to_git(path, buf->buf, buf->len, buf, 0);\n \t\treturn 0;\n \tdefault:\n@@ -2028,7 +2030,7 @@ static void update_pre_post_images(struct image *preimage,\n \t\t\tctx++;\n \t\t}\n \t\tif (preimage->nr <= ctx)\n-\t\t\tdie(\"oops\");\n+\t\t\tdie(_(\"oops\"));\n \n \t\t/* and copy it in, while fixing the line length */\n \t\tlen = preimage->line[ctx].len;\n@@ -2540,7 +2542,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tif (apply_verbosely)\n-\t\t\t\terror(\"invalid start of line: '%c'\", first);\n+\t\t\t\terror(_(\"invalid start of line: '%c'\"), first);\n \t\t\treturn -1;\n \t\t}\n \t\tif (added_blank_line) {\n@@ -2657,9 +2659,9 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,\n \t\t\tint offset = applied_pos - pos;\n \t\t\tif (apply_in_reverse)\n \t\t\t\toffset = 0 - offset;\n-\t\t\tfprintf(stderr,\n-\t\t\t\t\"Hunk #%d succeeded at %d (offset %d lines).\\n\",\n-\t\t\t\tnth_fragment, applied_pos + 1, offset);\n+\t\t\tfprintf_ln(stderr,\n+\t\t\t\t   _(\"Hunk #%d succeeded at %d (offset %d lines).\"),\n+\t\t\t\t   nth_fragment, applied_pos + 1, offset);\n \t\t}\n \n \t\t/*\n@@ -2668,13 +2670,13 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,\n \t\t */\n \t\tif ((leading != frag->leading) ||\n \t\t    (trailing != frag->trailing))\n-\t\t\tfprintf(stderr, \"Context reduced to (%ld/%ld)\"\n-\t\t\t\t\" to apply fragment at %d\\n\",\n-\t\t\t\tleading, trailing, applied_pos+1);\n+\t\t\tfprintf_ln(stderr, _(\"Context reduced to (%ld/%ld)\"\n+\t\t\t\t\t     \" to apply fragment at %d\"),\n+\t\t\t\t   leading, trailing, applied_pos+1);\n \t\tupdate_image(img, applied_pos, &preimage, &postimage);\n \t} else {\n \t\tif (apply_verbosely)\n-\t\t\terror(\"while searching for:\\n%.*s\",\n+\t\t\terror(_(\"while searching for:\\n%.*s\"),\n \t\t\t      (int)(old - oldlines), oldlines);\n \t}\n \n@@ -2693,7 +2695,7 @@ static int apply_binary_fragment(struct image *img, struct patch *patch)\n \tvoid *dst;\n \n \tif (!fragment)\n-\t\treturn error(\"missing binary patch data for '%s'\",\n+\t\treturn error(_(\"missing binary patch data for '%s'\"),\n \t\t\t     patch->new_name ?\n \t\t\t     patch->new_name :\n \t\t\t     patch->old_name);\n@@ -2790,13 +2792,13 @@ static int apply_binary(struct image *img, struct patch *patch)\n \t\t * in the patch->fragments->{patch,size}.\n \t\t */\n \t\tif (apply_binary_fragment(img, patch))\n-\t\t\treturn error(\"binary patch does not apply to '%s'\",\n+\t\t\treturn error(_(\"binary patch does not apply to '%s'\"),\n \t\t\t\t     name);\n \n \t\t/* verify that the result matches */\n \t\thash_sha1_file(img->buf, img->len, blob_type, sha1);\n \t\tif (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))\n-\t\t\treturn error(\"binary patch to '%s' creates incorrect result (expecting %s, got %s)\",\n+\t\t\treturn error(_(\"binary patch to '%s' creates incorrect result (expecting %s, got %s)\"),\n \t\t\t\tname, patch->new_sha1_prefix, sha1_to_hex(sha1));\n \t}\n \n@@ -2817,7 +2819,7 @@ static int apply_fragments(struct image *img, struct patch *patch)\n \twhile (frag) {\n \t\tnth++;\n \t\tif (apply_one_fragment(img, frag, inaccurate_eof, ws_rule, nth)) {\n-\t\t\terror(\"patch failed: %s:%ld\", name, frag->oldpos);\n+\t\t\terror(_(\"patch failed: %s:%ld\"), name, frag->oldpos);\n \t\t\tif (!apply_with_reject)\n \t\t\t\treturn -1;\n \t\t\tfrag->rejected = 1;\n@@ -2932,14 +2934,14 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *\n \tif (!(patch->is_copy || patch->is_rename) &&\n \t    (tpatch = in_fn_table(patch->old_name)) != NULL && !to_be_deleted(tpatch)) {\n \t\tif (was_deleted(tpatch)) {\n-\t\t\treturn error(\"patch %s has been renamed/deleted\",\n+\t\t\treturn error(_(\"patch %s has been renamed/deleted\"),\n \t\t\t\tpatch->old_name);\n \t\t}\n \t\t/* We have a patched copy in memory use that */\n \t\tstrbuf_add(&buf, tpatch->result, tpatch->resultsize);\n \t} else if (cached) {\n \t\tif (read_file_or_gitlink(ce, &buf))\n-\t\t\treturn error(\"read of %s failed\", patch->old_name);\n+\t\t\treturn error(_(\"read of %s failed\"), patch->old_name);\n \t} else if (patch->old_name) {\n \t\tif (S_ISGITLINK(patch->old_mode)) {\n \t\t\tif (ce) {\n@@ -2953,7 +2955,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *\n \t\t\t}\n \t\t} else {\n \t\t\tif (read_old_data(st, patch->old_name, &buf))\n-\t\t\t\treturn error(\"read of %s failed\", patch->old_name);\n+\t\t\t\treturn error(_(\"read of %s failed\"), patch->old_name);\n \t\t}\n \t}\n \n@@ -2968,7 +2970,7 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *\n \tfree(image.line_allocated);\n \n \tif (0 < patch->is_delete && patch->resultsize)\n-\t\treturn error(\"removal patch leaves file contents\");\n+\t\treturn error(_(\"removal patch leaves file contents\"));\n \n \treturn 0;\n }\n@@ -2989,7 +2991,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)\n \t\tif (has_symlink_leading_path(new_name, strlen(new_name)))\n \t\t\treturn 0;\n \n-\t\treturn error(\"%s: already exists in working directory\", new_name);\n+\t\treturn error(_(\"%s: already exists in working directory\"), new_name);\n \t}\n \telse if ((errno != ENOENT) && (errno != ENOTDIR))\n \t\treturn error(\"%s: %s\", new_name, strerror(errno));\n@@ -3027,12 +3029,12 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s\n \tif (!(patch->is_copy || patch->is_rename) &&\n \t    (tpatch = in_fn_table(old_name)) != NULL && !to_be_deleted(tpatch)) {\n \t\tif (was_deleted(tpatch))\n-\t\t\treturn error(\"%s: has been deleted/renamed\", old_name);\n+\t\t\treturn error(_(\"%s: has been deleted/renamed\"), old_name);\n \t\tst_mode = tpatch->new_mode;\n \t} else if (!cached) {\n \t\tstat_ret = lstat(old_name, st);\n \t\tif (stat_ret && errno != ENOENT)\n-\t\t\treturn error(\"%s: %s\", old_name, strerror(errno));\n+\t\t\treturn error(_(\"%s: %s\"), old_name, strerror(errno));\n \t}\n \n \tif (to_be_deleted(tpatch))\n@@ -3043,7 +3045,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s\n \t\tif (pos < 0) {\n \t\t\tif (patch->is_new < 0)\n \t\t\t\tgoto is_new;\n-\t\t\treturn error(\"%s: does not exist in index\", old_name);\n+\t\t\treturn error(_(\"%s: does not exist in index\"), old_name);\n \t\t}\n \t\t*ce = active_cache[pos];\n \t\tif (stat_ret < 0) {\n@@ -3057,13 +3059,13 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s\n \t\t\t\treturn -1;\n \t\t}\n \t\tif (!cached && verify_index_match(*ce, st))\n-\t\t\treturn error(\"%s: does not match index\", old_name);\n+\t\t\treturn error(_(\"%s: does not match index\"), old_name);\n \t\tif (cached)\n \t\t\tst_mode = (*ce)->ce_mode;\n \t} else if (stat_ret < 0) {\n \t\tif (patch->is_new < 0)\n \t\t\tgoto is_new;\n-\t\treturn error(\"%s: %s\", old_name, strerror(errno));\n+\t\treturn error(_(\"%s: %s\"), old_name, strerror(errno));\n \t}\n \n \tif (!cached && !tpatch)\n@@ -3074,9 +3076,9 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s\n \tif (!patch->old_mode)\n \t\tpatch->old_mode = st_mode;\n \tif ((st_mode ^ patch->old_mode) & S_IFMT)\n-\t\treturn error(\"%s: wrong type\", old_name);\n+\t\treturn error(_(\"%s: wrong type\"), old_name);\n \tif (st_mode != patch->old_mode)\n-\t\twarning(\"%s has type %o, expected %o\",\n+\t\twarning(_(\"%s has type %o, expected %o\"),\n \t\t\told_name, st_mode, patch->old_mode);\n \tif (!patch->new_mode && !patch->is_delete)\n \t\tpatch->new_mode = st_mode;\n@@ -3126,7 +3128,7 @@ static int check_patch(struct patch *patch)\n \t\tif (check_index &&\n \t\t    cache_name_pos(new_name, strlen(new_name)) >= 0 &&\n \t\t    !ok_if_exists)\n-\t\t\treturn error(\"%s: already exists in index\", new_name);\n+\t\t\treturn error(_(\"%s: already exists in index\"), new_name);\n \t\tif (!cached) {\n \t\t\tint err = check_to_create_blob(new_name, ok_if_exists);\n \t\t\tif (err)\n@@ -3145,13 +3147,13 @@ static int check_patch(struct patch *patch)\n \t\tif (!patch->new_mode)\n \t\t\tpatch->new_mode = patch->old_mode;\n \t\tif ((patch->old_mode ^ patch->new_mode) & S_IFMT)\n-\t\t\treturn error(\"new mode (%o) of %s does not match old mode (%o)%s%s\",\n+\t\t\treturn error(_(\"new mode (%o) of %s does not match old mode (%o)%s%s\"),\n \t\t\t\tpatch->new_mode, new_name, patch->old_mode,\n \t\t\t\tsame ? \"\" : \" of \", same ? \"\" : old_name);\n \t}\n \n \tif (apply_data(patch, &st, ce) < 0)\n-\t\treturn error(\"%s: patch does not apply\", name);\n+\t\treturn error(_(\"%s: patch does not apply\"), name);\n \tpatch->rejected = 0;\n \treturn 0;\n }\n@@ -3219,7 +3221,7 @@ static void build_fake_ancestor(struct patch *list, const char *filename)\n \n \t\tce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);\n \t\tif (!ce)\n-\t\t\tdie(\"make_cache_entry failed for path '%s'\", name);\n+\t\t\tdie(_(\"make_cache_entry failed for path '%s'\"), name);\n \t\tif (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))\n \t\t\tdie (\"Could not add %s to temporary index\", name);\n \t}\n@@ -3362,7 +3364,7 @@ static void remove_file(struct patch *patch, int rmdir_empty)\n {\n \tif (update_index) {\n \t\tif (remove_file_from_cache(patch->old_name) < 0)\n-\t\t\tdie(\"unable to remove %s from index\", patch->old_name);\n+\t\t\tdie(_(\"unable to remove %s from index\"), patch->old_name);\n \t}\n \tif (!cached) {\n \t\tif (!remove_or_warn(patch->old_mode, patch->old_name) && rmdir_empty) {\n@@ -3389,19 +3391,19 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned\n \t\tconst char *s = buf;\n \n \t\tif (get_sha1_hex(s + strlen(\"Subproject commit \"), ce->sha1))\n-\t\t\tdie(\"corrupt patch for subproject %s\", path);\n+\t\t\tdie(_(\"corrupt patch for subproject %s\"), path);\n \t} else {\n \t\tif (!cached) {\n \t\t\tif (lstat(path, &st) < 0)\n-\t\t\t\tdie_errno(\"unable to stat newly created file '%s'\",\n+\t\t\t\tdie_errno(_(\"unable to stat newly created file '%s'\"),\n \t\t\t\t\t  path);\n \t\t\tfill_stat_cache_info(ce, &st);\n \t\t}\n \t\tif (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)\n-\t\t\tdie(\"unable to create backing store for newly created file %s\", path);\n+\t\t\tdie(_(\"unable to create backing store for newly created file %s\"), path);\n \t}\n \tif (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)\n-\t\tdie(\"unable to add cache entry for %s\", path);\n+\t\tdie(_(\"unable to add cache entry for %s\"), path);\n }\n \n static int try_create_file(const char *path, unsigned int mode, const char *buf, unsigned long size)\n@@ -3434,7 +3436,7 @@ static int try_create_file(const char *path, unsigned int mode, const char *buf,\n \tstrbuf_release(&nbuf);\n \n \tif (close(fd) < 0)\n-\t\tdie_errno(\"closing file '%s'\", path);\n+\t\tdie_errno(_(\"closing file '%s'\"), path);\n \treturn 0;\n }\n \n@@ -3483,7 +3485,7 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned\n \t\t\t++nr;\n \t\t}\n \t}\n-\tdie_errno(\"unable to write file '%s' mode %o\", path, mode);\n+\tdie_errno(_(\"unable to write file '%s' mode %o\"), path, mode);\n }\n \n static void create_file(struct patch *patch)\n@@ -3546,7 +3548,7 @@ static int write_out_one_reject(struct patch *patch)\n \t * contents are marked \"rejected\" at the patch level.\n \t */\n \tif (!patch->new_name)\n-\t\tdie(\"internal error\");\n+\t\tdie(_(\"internal error\"));\n \n \t/* Say this even without --verbose */\n \tsay_patch_name(stderr, \"Applying patch \", patch, \" with\");\n@@ -3555,7 +3557,7 @@ static int write_out_one_reject(struct patch *patch)\n \tcnt = strlen(patch->new_name);\n \tif (ARRAY_SIZE(namebuf) <= cnt + 5) {\n \t\tcnt = ARRAY_SIZE(namebuf) - 5;\n-\t\twarning(\"truncating .rej filename to %.*s.rej\",\n+\t\twarning(_(\"truncating .rej filename to %.*s.rej\"),\n \t\t\tcnt - 1, patch->new_name);\n \t}\n \tmemcpy(namebuf, patch->new_name, cnt);\n@@ -3563,7 +3565,7 @@ static int write_out_one_reject(struct patch *patch)\n \n \trej = fopen(namebuf, \"w\");\n \tif (!rej)\n-\t\treturn error(\"cannot open %s: %s\", namebuf, strerror(errno));\n+\t\treturn error(_(\"cannot open %s: %s\"), namebuf, strerror(errno));\n \n \t/* Normal git tools never deal with .rej, so do not pretend\n \t * this is a git patch by saying --git nor give extended\n@@ -3576,10 +3578,10 @@ static int write_out_one_reject(struct patch *patch)\n \t     frag;\n \t     cnt++, frag = frag->next) {\n \t\tif (!frag->rejected) {\n-\t\t\tfprintf(stderr, \"Hunk #%d applied cleanly.\\n\", cnt);\n+\t\t\tfprintf_ln(stderr, _(\"Hunk #%d applied cleanly.\"), cnt);\n \t\t\tcontinue;\n \t\t}\n-\t\tfprintf(stderr, \"Rejected hunk #%d.\\n\", cnt);\n+\t\tfprintf_ln(stderr, _(\"Rejected hunk #%d.\"), cnt);\n \t\tfprintf(rej, \"%.*s\", frag->size, frag->patch);\n \t\tif (frag->patch[frag->size-1] != '\\n')\n \t\t\tfputc('\\n', rej);\n@@ -3720,7 +3722,7 @@ static int apply_patch(int fd, const char *filename, int options)\n \t}\n \n \tif (!list && !skipped_patch)\n-\t\tdie(\"unrecognized input\");\n+\t\tdie(_(\"unrecognized input\"));\n \n \tif (whitespace_error && (ws_error_action == die_on_ws_error))\n \t\tapply = 0;\n@@ -3731,7 +3733,7 @@ static int apply_patch(int fd, const char *filename, int options)\n \n \tif (check_index) {\n \t\tif (read_cache() < 0)\n-\t\t\tdie(\"unable to read index file\");\n+\t\t\tdie(_(\"unable to read index file\"));\n \t}\n \n \tif ((check || apply) &&\n@@ -3844,66 +3846,66 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)\n \tconst char *whitespace_option = NULL;\n \n \tstruct option builtin_apply_options[] = {\n-\t\t{ OPTION_CALLBACK, 0, \"exclude\", NULL, \"path\",\n-\t\t\t\"don't apply changes matching the given path\",\n+\t\t{ OPTION_CALLBACK, 0, \"exclude\", NULL, N_(\"path\"),\n+\t\t\tN_(\"don't apply changes matching the given path\"),\n \t\t\t0, option_parse_exclude },\n-\t\t{ OPTION_CALLBACK, 0, \"include\", NULL, \"path\",\n-\t\t\t\"apply changes matching the given path\",\n+\t\t{ OPTION_CALLBACK, 0, \"include\", NULL, N_(\"path\"),\n+\t\t\tN_(\"apply changes matching the given path\"),\n \t\t\t0, option_parse_include },\n-\t\t{ OPTION_CALLBACK, 'p', NULL, NULL, \"num\",\n-\t\t\t\"remove <num> leading slashes from traditional diff paths\",\n+\t\t{ OPTION_CALLBACK, 'p', NULL, NULL, N_(\"num\"),\n+\t\t\tN_(\"remove <num> leading slashes from traditional diff paths\"),\n \t\t\t0, option_parse_p },\n \t\tOPT_BOOLEAN(0, \"no-add\", &no_add,\n-\t\t\t\"ignore additions made by the patch\"),\n+\t\t\tN_(\"ignore additions made by the patch\")),\n \t\tOPT_BOOLEAN(0, \"stat\", &diffstat,\n-\t\t\t\"instead of applying the patch, output diffstat for the input\"),\n+\t\t\tN_(\"instead of applying the patch, output diffstat for the input\")),\n \t\tOPT_NOOP_NOARG(0, \"allow-binary-replacement\"),\n \t\tOPT_NOOP_NOARG(0, \"binary\"),\n \t\tOPT_BOOLEAN(0, \"numstat\", &numstat,\n-\t\t\t\"shows number of added and deleted lines in decimal notation\"),\n+\t\t\tN_(\"shows number of added and deleted lines in decimal notation\")),\n \t\tOPT_BOOLEAN(0, \"summary\", &summary,\n-\t\t\t\"instead of applying the patch, output a summary for the input\"),\n+\t\t\tN_(\"instead of applying the patch, output a summary for the input\")),\n \t\tOPT_BOOLEAN(0, \"check\", &check,\n-\t\t\t\"instead of applying the patch, see if the patch is applicable\"),\n+\t\t\tN_(\"instead of applying the patch, see if the patch is applicable\")),\n \t\tOPT_BOOLEAN(0, \"index\", &check_index,\n-\t\t\t\"make sure the patch is applicable to the current index\"),\n+\t\t\tN_(\"make sure the patch is applicable to the current index\")),\n \t\tOPT_BOOLEAN(0, \"cached\", &cached,\n-\t\t\t\"apply a patch without touching the working tree\"),\n+\t\t\tN_(\"apply a patch without touching the working tree\")),\n \t\tOPT_BOOLEAN(0, \"apply\", &force_apply,\n-\t\t\t\"also apply the patch (use with --stat/--summary/--check)\"),\n+\t\t\tN_(\"also apply the patch (use with --stat/--summary/--check)\")),\n \t\tOPT_FILENAME(0, \"build-fake-ancestor\", &fake_ancestor,\n-\t\t\t\"build a temporary index based on embedded index information\"),\n+\t\t\tN_(\"build a temporary index based on embedded index information\")),\n \t\t{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,\n-\t\t\t\"paths are separated with NUL character\",\n+\t\t\tN_(\"paths are separated with NUL character\"),\n \t\t\tPARSE_OPT_NOARG, option_parse_z },\n \t\tOPT_INTEGER('C', NULL, &p_context,\n-\t\t\t\t\"ensure at least <n> lines of context match\"),\n-\t\t{ OPTION_CALLBACK, 0, \"whitespace\", &whitespace_option, \"action\",\n-\t\t\t\"detect new or modified lines that have whitespace errors\",\n+\t\t\t\tN_(\"ensure at least <n> lines of context match\")),\n+\t\t{ OPTION_CALLBACK, 0, \"whitespace\", &whitespace_option, N_(\"action\"),\n+\t\t\tN_(\"detect new or modified lines that have whitespace errors\"),\n \t\t\t0, option_parse_whitespace },\n \t\t{ OPTION_CALLBACK, 0, \"ignore-space-change\", NULL, NULL,\n-\t\t\t\"ignore changes in whitespace when finding context\",\n+\t\t\tN_(\"ignore changes in whitespace when finding context\"),\n \t\t\tPARSE_OPT_NOARG, option_parse_space_change },\n \t\t{ OPTION_CALLBACK, 0, \"ignore-whitespace\", NULL, NULL,\n-\t\t\t\"ignore changes in whitespace when finding context\",\n+\t\t\tN_(\"ignore changes in whitespace when finding context\"),\n \t\t\tPARSE_OPT_NOARG, option_parse_space_change },\n \t\tOPT_BOOLEAN('R', \"reverse\", &apply_in_reverse,\n-\t\t\t\"apply the patch in reverse\"),\n+\t\t\tN_(\"apply the patch in reverse\")),\n \t\tOPT_BOOLEAN(0, \"unidiff-zero\", &unidiff_zero,\n-\t\t\t\"don't expect at least one line of context\"),\n+\t\t\tN_(\"don't expect at least one line of context\")),\n \t\tOPT_BOOLEAN(0, \"reject\", &apply_with_reject,\n-\t\t\t\"leave the rejected hunks in corresponding *.rej files\"),\n+\t\t\tN_(\"leave the rejected hunks in corresponding *.rej files\")),\n \t\tOPT_BOOLEAN(0, \"allow-overlap\", &allow_overlap,\n-\t\t\t\"allow overlapping hunks\"),\n-\t\tOPT__VERBOSE(&apply_verbosely, \"be verbose\"),\n+\t\t\tN_(\"allow overlapping hunks\")),\n+\t\tOPT__VERBOSE(&apply_verbosely, N_(\"be verbose\")),\n \t\tOPT_BIT(0, \"inaccurate-eof\", &options,\n-\t\t\t\"tolerate incorrectly detected missing new-line at the end of file\",\n+\t\t\tN_(\"tolerate incorrectly detected missing new-line at the end of file\"),\n \t\t\tINACCURATE_EOF),\n \t\tOPT_BIT(0, \"recount\", &options,\n-\t\t\t\"do not trust the line counts in the hunk headers\",\n+\t\t\tN_(\"do not trust the line counts in the hunk headers\"),\n \t\t\tRECOUNT),\n-\t\t{ OPTION_CALLBACK, 0, \"directory\", NULL, \"root\",\n-\t\t\t\"prepend <root> to all filenames\",\n+\t\t{ OPTION_CALLBACK, 0, \"directory\", NULL, N_(\"root\"),\n+\t\t\tN_(\"prepend <root> to all filenames\"),\n \t\t\t0, option_parse_directory },\n \t\tOPT_END()\n \t};\n@@ -3924,10 +3926,10 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)\n \tif (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))\n \t\tapply = 0;\n \tif (check_index && is_not_gitdir)\n-\t\tdie(\"--index outside a repository\");\n+\t\tdie(_(\"--index outside a repository\"));\n \tif (cached) {\n \t\tif (is_not_gitdir)\n-\t\t\tdie(\"--cached outside a repository\");\n+\t\t\tdie(_(\"--cached outside a repository\"));\n \t\tcheck_index = 1;\n \t}\n \tfor (i = 0; i < argc; i++) {\n@@ -3943,7 +3945,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)\n \n \t\tfd = open(arg, O_RDONLY);\n \t\tif (fd < 0)\n-\t\t\tdie_errno(\"can't open patch '%s'\", arg);\n+\t\t\tdie_errno(_(\"can't open patch '%s'\"), arg);\n \t\tread_stdin = 0;\n \t\tset_default_whitespace_mode(whitespace_option);\n \t\terrs |= apply_patch(fd, arg, options);\n@@ -3957,32 +3959,32 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)\n \t\t    squelch_whitespace_errors < whitespace_error) {\n \t\t\tint squelched =\n \t\t\t\twhitespace_error - squelch_whitespace_errors;\n-\t\t\twarning(\"squelched %d \"\n-\t\t\t\t\"whitespace error%s\",\n-\t\t\t\tsquelched,\n-\t\t\t\tsquelched == 1 ? \"\" : \"s\");\n+\t\t\twarning(Q_(\"squelched %d whitespace error\",\n+\t\t\t\t   \"squelched %d whitespace errors\",\n+\t\t\t\t   squelched),\n+\t\t\t\tsquelched);\n \t\t}\n \t\tif (ws_error_action == die_on_ws_error)\n-\t\t\tdie(\"%d line%s add%s whitespace errors.\",\n-\t\t\t    whitespace_error,\n-\t\t\t    whitespace_error == 1 ? \"\" : \"s\",\n-\t\t\t    whitespace_error == 1 ? \"s\" : \"\");\n+\t\t\tdie(Q_(\"%d line adds whitespace errors.\",\n+\t\t\t       \"%d lines add whitespace errors.\",\n+\t\t\t       whitespace_error),\n+\t\t\t    whitespace_error);\n \t\tif (applied_after_fixing_ws && apply)\n \t\t\twarning(\"%d line%s applied after\"\n \t\t\t\t\" fixing whitespace errors.\",\n \t\t\t\tapplied_after_fixing_ws,\n \t\t\t\tapplied_after_fixing_ws == 1 ? \"\" : \"s\");\n \t\telse if (whitespace_error)\n-\t\t\twarning(\"%d line%s add%s whitespace errors.\",\n-\t\t\t\twhitespace_error,\n-\t\t\t\twhitespace_error == 1 ? \"\" : \"s\",\n-\t\t\t\twhitespace_error == 1 ? \"s\" : \"\");\n+\t\t\twarning(Q_(\"%d line adds whitespace errors.\",\n+\t\t\t\t   \"%d lines add whitespace errors.\",\n+\t\t\t\t   whitespace_error),\n+\t\t\t\twhitespace_error);\n \t}\n \n \tif (update_index) {\n \t\tif (write_cache(newfd, active_cache, active_nr) ||\n \t\t    commit_locked_index(&lock_file))\n-\t\t\tdie(\"Unable to write new index file\");\n+\t\t\tdie(_(\"Unable to write new index file\"));\n \t}\n \n \treturn !!errs;\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189401","messageId":"1334580603-11577-10-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:50:01Z","receivedAt":"2012-04-16T12:50:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n builtin/apply.c |   33 +++++++++++++++++++--------------\n 1 files changed, 19 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 6e9a02e..87922cf 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -335,22 +335,25 @@ static void clear_image(struct image *image)\n \timage->len = 0;\n }\n \n-static void say_patch_name(FILE *output, const char *pre,\n-\t\t\t   struct patch *patch, const char *post)\n+/* fmt must contain _one_ %s and no other substitution */\n+static void say_patch_name(FILE *output, struct patch *patch, const char *fmt)\n {\n-\tfputs(pre, output);\n+\tstruct strbuf sb = STRBUF_INIT;\n+\n \tif (patch->old_name && patch->new_name &&\n \t    strcmp(patch->old_name, patch->new_name)) {\n-\t\tquote_c_style(patch->old_name, NULL, output, 0);\n-\t\tfputs(\" => \", output);\n-\t\tquote_c_style(patch->new_name, NULL, output, 0);\n+\t\tquote_c_style(patch->old_name, &sb, NULL, 0);\n+\t\tstrbuf_addstr(&sb, \" => \");\n+\t\tquote_c_style(patch->new_name, &sb, NULL, 0);\n \t} else {\n \t\tconst char *n = patch->new_name;\n \t\tif (!n)\n \t\t\tn = patch->old_name;\n-\t\tquote_c_style(n, NULL, output, 0);\n+\t\tquote_c_style(n, &sb, NULL, 0);\n \t}\n-\tfputs(post, output);\n+\tfprintf(output, fmt, sb.buf);\n+\tfprintf(output, \"\\n\");\n+\tstrbuf_release(&sb);\n }\n \n #define CHUNKSIZE (8192)\n@@ -3165,8 +3168,8 @@ static int check_patch_list(struct patch *patch)\n \tprepare_fn_table(patch);\n \twhile (patch) {\n \t\tif (apply_verbosely)\n-\t\t\tsay_patch_name(stderr,\n-\t\t\t\t       \"Checking patch \", patch, \"...\\n\");\n+\t\t\tsay_patch_name(stderr, patch,\n+\t\t\t\t       _(\"Checking patch %s...\"));\n \t\terr |= check_patch(patch);\n \t\tpatch = patch->next;\n \t}\n@@ -3530,6 +3533,7 @@ static int write_out_one_reject(struct patch *patch)\n \tchar namebuf[PATH_MAX];\n \tstruct fragment *frag;\n \tint cnt = 0;\n+\tstruct strbuf sb = STRBUF_INIT;\n \n \tfor (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {\n \t\tif (!frag->rejected)\n@@ -3539,8 +3543,8 @@ static int write_out_one_reject(struct patch *patch)\n \n \tif (!cnt) {\n \t\tif (apply_verbosely)\n-\t\t\tsay_patch_name(stderr,\n-\t\t\t\t       \"Applied patch \", patch, \" cleanly.\\n\");\n+\t\t\tsay_patch_name(stderr, patch,\n+\t\t\t\t       _(\"Applied patch %s cleanly.\"));\n \t\treturn 0;\n \t}\n \n@@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)\n \t\tdie(_(\"internal error\"));\n \n \t/* Say this even without --verbose */\n-\tsay_patch_name(stderr, \"Applying patch \", patch, \" with\");\n-\tfprintf(stderr, \" %d rejects...\\n\", cnt);\n+\tstrbuf_addf(&sb, _(\"Applying patch %%s with %d rejects...\"), cnt);\n+\tsay_patch_name(stderr, patch, sb.buf);\n+\tstrbuf_release(&sb);\n \n \tcnt = strlen(patch->new_name);\n \tif (ARRAY_SIZE(namebuf) <= cnt + 5) {\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189402","messageId":"1334580603-11577-11-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 10/11] i18n: index-pack: mark strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:50:02Z","receivedAt":"2012-04-16T12:50:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n builtin/index-pack.c |  117 +++++++++++++++++++++++++------------------------\n 1 files changed, 60 insertions(+), 57 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex dd1c5c9..1da8361 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -81,7 +81,7 @@ static int mark_link(struct object *obj, int type, void *data)\n \t\treturn -1;\n \n \tif (type != OBJ_ANY && obj->type != type)\n-\t\tdie(\"object type mismatch at %s\", sha1_to_hex(obj->sha1));\n+\t\tdie(_(\"object type mismatch at %s\"), sha1_to_hex(obj->sha1));\n \n \tobj->flags |= FLAG_LINK;\n \treturn 0;\n@@ -101,7 +101,7 @@ static void check_object(struct object *obj)\n \t\tunsigned long size;\n \t\tint type = sha1_object_info(obj->sha1, &size);\n \t\tif (type != obj->type || type <= 0)\n-\t\t\tdie(\"object of unexpected type\");\n+\t\t\tdie(_(\"object of unexpected type\"));\n \t\tobj->flags |= FLAG_CHECKED;\n \t\treturn;\n \t}\n@@ -138,15 +138,15 @@ static void *fill(int min)\n \tif (min <= input_len)\n \t\treturn input_buffer + input_offset;\n \tif (min > sizeof(input_buffer))\n-\t\tdie(\"cannot fill %d bytes\", min);\n+\t\tdie(_(\"cannot fill %d bytes\"), min);\n \tflush();\n \tdo {\n \t\tssize_t ret = xread(input_fd, input_buffer + input_len,\n \t\t\t\tsizeof(input_buffer) - input_len);\n \t\tif (ret <= 0) {\n \t\t\tif (!ret)\n-\t\t\t\tdie(\"early EOF\");\n-\t\t\tdie_errno(\"read error on input\");\n+\t\t\t\tdie(_(\"early EOF\"));\n+\t\t\tdie_errno(_(\"read error on input\"));\n \t\t}\n \t\tinput_len += ret;\n \t\tif (from_stdin)\n@@ -158,14 +158,14 @@ static void *fill(int min)\n static void use(int bytes)\n {\n \tif (bytes > input_len)\n-\t\tdie(\"used more bytes than were available\");\n+\t\tdie(_(\"used more bytes than were available\"));\n \tinput_crc32 = crc32(input_crc32, input_buffer + input_offset, bytes);\n \tinput_len -= bytes;\n \tinput_offset += bytes;\n \n \t/* make sure off_t is sufficiently large not to wrap */\n \tif (signed_add_overflows(consumed_bytes, bytes))\n-\t\tdie(\"pack too large for current definition of off_t\");\n+\t\tdie(_(\"pack too large for current definition of off_t\"));\n \tconsumed_bytes += bytes;\n }\n \n@@ -181,12 +181,12 @@ static const char *open_pack_file(const char *pack_name)\n \t\t} else\n \t\t\toutput_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);\n \t\tif (output_fd < 0)\n-\t\t\tdie_errno(\"unable to create '%s'\", pack_name);\n+\t\t\tdie_errno(_(\"unable to create '%s'\"), pack_name);\n \t\tpack_fd = output_fd;\n \t} else {\n \t\tinput_fd = open(pack_name, O_RDONLY);\n \t\tif (input_fd < 0)\n-\t\t\tdie_errno(\"cannot open packfile '%s'\", pack_name);\n+\t\t\tdie_errno(_(\"cannot open packfile '%s'\"), pack_name);\n \t\toutput_fd = -1;\n \t\tpack_fd = input_fd;\n \t}\n@@ -200,7 +200,7 @@ static void parse_pack_header(void)\n \n \t/* Header consistency check */\n \tif (hdr->hdr_signature != htonl(PACK_SIGNATURE))\n-\t\tdie(\"pack signature mismatch\");\n+\t\tdie(_(\"pack signature mismatch\"));\n \tif (!pack_version_ok(hdr->hdr_version))\n \t\tdie(\"pack version %\"PRIu32\" unsupported\",\n \t\t\tntohl(hdr->hdr_version));\n@@ -220,7 +220,7 @@ static NORETURN void bad_object(unsigned long offset, const char *format, ...)\n \tva_start(params, format);\n \tvsnprintf(buf, sizeof(buf), format, params);\n \tva_end(params);\n-\tdie(\"pack has bad object at offset %lu: %s\", offset, buf);\n+\tdie(_(\"pack has bad object at offset %lu: %s\"), offset, buf);\n }\n \n static struct base_data *alloc_base_data(void)\n@@ -294,7 +294,7 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)\n \t\tuse(input_len - stream.avail_in);\n \t} while (status == Z_OK);\n \tif (stream.total_out != size || status != Z_STREAM_END)\n-\t\tbad_object(offset, \"inflate returned %d\", status);\n+\t\tbad_object(offset, _(\"inflate returned %d\"), status);\n \tgit_inflate_end(&stream);\n \treturn buf;\n }\n@@ -339,7 +339,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_\n \t\twhile (c & 128) {\n \t\t\tbase_offset += 1;\n \t\t\tif (!base_offset || MSB(base_offset, 7))\n-\t\t\t\tbad_object(obj->idx.offset, \"offset value overflow for delta base object\");\n+\t\t\t\tbad_object(obj->idx.offset, _(\"offset value overflow for delta base object\"));\n \t\t\tp = fill(1);\n \t\t\tc = *p;\n \t\t\tuse(1);\n@@ -347,7 +347,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_\n \t\t}\n \t\tdelta_base->offset = obj->idx.offset - base_offset;\n \t\tif (delta_base->offset <= 0 || delta_base->offset >= obj->idx.offset)\n-\t\t\tbad_object(obj->idx.offset, \"delta base offset is out of bound\");\n+\t\t\tbad_object(obj->idx.offset, _(\"delta base offset is out of bound\"));\n \t\tbreak;\n \tcase OBJ_COMMIT:\n \tcase OBJ_TREE:\n@@ -355,7 +355,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_\n \tcase OBJ_TAG:\n \t\tbreak;\n \tdefault:\n-\t\tbad_object(obj->idx.offset, \"unknown object type %d\", obj->type);\n+\t\tbad_object(obj->idx.offset, _(\"unknown object type %d\"), obj->type);\n \t}\n \tobj->hdr_size = consumed_bytes - obj->idx.offset;\n \n@@ -384,9 +384,9 @@ static void *get_data_from_pack(struct object_entry *obj)\n \t\tssize_t n = (len < 64*1024) ? len : 64*1024;\n \t\tn = pread(pack_fd, inbuf, n, from);\n \t\tif (n < 0)\n-\t\t\tdie_errno(\"cannot pread pack file\");\n+\t\t\tdie_errno(_(\"cannot pread pack file\"));\n \t\tif (!n)\n-\t\t\tdie(\"premature end of pack file, %lu bytes missing\", len);\n+\t\t\tdie(_(\"premature end of pack file, %lu bytes missing\"), len);\n \t\tfrom += n;\n \t\tlen -= n;\n \t\tstream.next_in = inbuf;\n@@ -396,7 +396,7 @@ static void *get_data_from_pack(struct object_entry *obj)\n \n \t/* This has been inflated OK when first encountered, so... */\n \tif (status != Z_STREAM_END || stream.total_out != obj->size)\n-\t\tdie(\"serious inflate inconsistency\");\n+\t\tdie(_(\"serious inflate inconsistency\"));\n \n \tgit_inflate_end(&stream);\n \tfree(inbuf);\n@@ -467,10 +467,10 @@ static void sha1_object(const void *data, unsigned long size,\n \t\tunsigned long has_size;\n \t\thas_data = read_sha1_file(sha1, &has_type, &has_size);\n \t\tif (!has_data)\n-\t\t\tdie(\"cannot read existing object %s\", sha1_to_hex(sha1));\n+\t\t\tdie(_(\"cannot read existing object %s\"), sha1_to_hex(sha1));\n \t\tif (size != has_size || type != has_type ||\n \t\t    memcmp(data, has_data, size) != 0)\n-\t\t\tdie(\"SHA1 COLLISION FOUND WITH %s !\", sha1_to_hex(sha1));\n+\t\t\tdie(_(\"SHA1 COLLISION FOUND WITH %s !\"), sha1_to_hex(sha1));\n \t\tfree(has_data);\n \t}\n \tif (strict) {\n@@ -479,7 +479,7 @@ static void sha1_object(const void *data, unsigned long size,\n \t\t\tif (blob)\n \t\t\t\tblob->object.flags |= FLAG_CHECKED;\n \t\t\telse\n-\t\t\t\tdie(\"invalid blob object %s\", sha1_to_hex(sha1));\n+\t\t\t\tdie(_(\"invalid blob object %s\"), sha1_to_hex(sha1));\n \t\t} else {\n \t\t\tstruct object *obj;\n \t\t\tint eaten;\n@@ -491,11 +491,11 @@ static void sha1_object(const void *data, unsigned long size,\n \t\t\t */\n \t\t\tobj = parse_object_buffer(sha1, type, size, buf, &eaten);\n \t\t\tif (!obj)\n-\t\t\t\tdie(\"invalid %s\", typename(type));\n+\t\t\t\tdie(_(\"invalid %s\"), typename(type));\n \t\t\tif (fsck_object(obj, 1, fsck_error_function))\n-\t\t\t\tdie(\"Error in object\");\n+\t\t\t\tdie(_(\"Error in object\"));\n \t\t\tif (fsck_walk(obj, mark_link, NULL))\n-\t\t\t\tdie(\"Not all child objects of %s are reachable\", sha1_to_hex(obj->sha1));\n+\t\t\t\tdie(_(\"Not all child objects of %s are reachable\"), sha1_to_hex(obj->sha1));\n \n \t\t\tif (obj->type == OBJ_TREE) {\n \t\t\t\tstruct tree *item = (struct tree *) obj;\n@@ -567,7 +567,7 @@ static void *get_base_data(struct base_data *c)\n \t\t\t\t&c->size);\n \t\t\tfree(raw);\n \t\t\tif (!c->data)\n-\t\t\t\tbad_object(obj->idx.offset, \"failed to apply delta\");\n+\t\t\t\tbad_object(obj->idx.offset, _(\"failed to apply delta\"));\n \t\t\tbase_cache_used += c->size;\n \t\t\tprune_base_data(c);\n \t\t}\n@@ -593,7 +593,7 @@ static void resolve_delta(struct object_entry *delta_obj,\n \t\t\t\t   delta_data, delta_obj->size, &result->size);\n \tfree(delta_data);\n \tif (!result->data)\n-\t\tbad_object(delta_obj->idx.offset, \"failed to apply delta\");\n+\t\tbad_object(delta_obj->idx.offset, _(\"failed to apply delta\"));\n \tsha1_object(result->data, result->size, delta_obj->real_type,\n \t\t    delta_obj->idx.sha1);\n \tnr_resolved_deltas++;\n@@ -697,7 +697,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \t */\n \tif (verbose)\n \t\tprogress = start_progress(\n-\t\t\t\tfrom_stdin ? \"Receiving objects\" : \"Indexing objects\",\n+\t\t\t\tfrom_stdin ? _(\"Receiving objects\") : _(\"Indexing objects\"),\n \t\t\t\tnr_objects);\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tstruct object_entry *obj = &objects[i];\n@@ -719,15 +719,15 @@ static void parse_pack_objects(unsigned char *sha1)\n \tflush();\n \tgit_SHA1_Final(sha1, &input_ctx);\n \tif (hashcmp(fill(20), sha1))\n-\t\tdie(\"pack is corrupted (SHA1 mismatch)\");\n+\t\tdie(_(\"pack is corrupted (SHA1 mismatch)\"));\n \tuse(20);\n \n \t/* If input_fd is a file, we should have reached its end now. */\n \tif (fstat(input_fd, &st))\n-\t\tdie_errno(\"cannot fstat packfile\");\n+\t\tdie_errno(_(\"cannot fstat packfile\"));\n \tif (S_ISREG(st.st_mode) &&\n \t\t\tlseek(input_fd, 0, SEEK_CUR) - input_len != st.st_size)\n-\t\tdie(\"pack has junk at the end\");\n+\t\tdie(_(\"pack has junk at the end\"));\n \n \tif (!nr_deltas)\n \t\treturn;\n@@ -745,7 +745,7 @@ static void parse_pack_objects(unsigned char *sha1)\n \t *   for some more deltas.\n \t */\n \tif (verbose)\n-\t\tprogress = start_progress(\"Resolving deltas\", nr_deltas);\n+\t\tprogress = start_progress(_(\"Resolving deltas\"), nr_deltas);\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tstruct object_entry *obj = &objects[i];\n \t\tstruct base_data *base_obj = alloc_base_data();\n@@ -778,7 +778,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)\n \t} while (status == Z_OK);\n \n \tif (status != Z_STREAM_END)\n-\t\tdie(\"unable to deflate appended object (%d)\", status);\n+\t\tdie(_(\"unable to deflate appended object (%d)\"), status);\n \tsize = stream.total_out;\n \tgit_deflate_end(&stream);\n \treturn size;\n@@ -857,7 +857,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)\n \n \t\tif (check_sha1_signature(d->base.sha1, base_obj->data,\n \t\t\t\tbase_obj->size, typename(type)))\n-\t\t\tdie(\"local object %s is corrupt\", sha1_to_hex(d->base.sha1));\n+\t\t\tdie(_(\"local object %s is corrupt\"), sha1_to_hex(d->base.sha1));\n \t\tbase_obj->obj = append_obj_to_pack(f, d->base.sha1,\n \t\t\t\t\tbase_obj->data, base_obj->size, type);\n \t\tfind_unresolved_deltas(base_obj);\n@@ -881,7 +881,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\tfsync_or_die(output_fd, curr_pack_name);\n \t\terr = close(output_fd);\n \t\tif (err)\n-\t\t\tdie_errno(\"error while closing pack file\");\n+\t\t\tdie_errno(_(\"error while closing pack file\"));\n \t}\n \n \tif (keep_msg) {\n@@ -894,7 +894,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \n \t\tif (keep_fd < 0) {\n \t\t\tif (errno != EEXIST)\n-\t\t\t\tdie_errno(\"cannot write keep file '%s'\",\n+\t\t\t\tdie_errno(_(\"cannot write keep file '%s'\"),\n \t\t\t\t\t  keep_name);\n \t\t} else {\n \t\t\tif (keep_msg_len > 0) {\n@@ -902,7 +902,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\t\t\twrite_or_die(keep_fd, \"\\n\", 1);\n \t\t\t}\n \t\t\tif (close(keep_fd) != 0)\n-\t\t\t\tdie_errno(\"cannot close written keep file '%s'\",\n+\t\t\t\tdie_errno(_(\"cannot close written keep file '%s'\"),\n \t\t\t\t    keep_name);\n \t\t\treport = \"keep\";\n \t\t}\n@@ -915,7 +915,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\t\tfinal_pack_name = name;\n \t\t}\n \t\tif (move_temp_to_file(curr_pack_name, final_pack_name))\n-\t\t\tdie(\"cannot store pack file\");\n+\t\t\tdie(_(\"cannot store pack file\"));\n \t} else if (from_stdin)\n \t\tchmod(final_pack_name, 0444);\n \n@@ -926,7 +926,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\t\tfinal_index_name = name;\n \t\t}\n \t\tif (move_temp_to_file(curr_index_name, final_index_name))\n-\t\t\tdie(\"cannot store index file\");\n+\t\t\tdie(_(\"cannot store index file\"));\n \t} else\n \t\tchmod(final_index_name, 0444);\n \n@@ -1015,9 +1015,9 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)\n \tstruct packed_git *p = add_packed_git(pack_name, strlen(pack_name), 1);\n \n \tif (!p)\n-\t\tdie(\"Cannot open existing pack file '%s'\", pack_name);\n+\t\tdie(_(\"Cannot open existing pack file '%s'\"), pack_name);\n \tif (open_pack_index(p))\n-\t\tdie(\"Cannot open existing pack idx file for '%s'\", pack_name);\n+\t\tdie(_(\"Cannot open existing pack idx file for '%s'\"), pack_name);\n \n \t/* Read the attributes from the existing idx file */\n \topts->version = p->index_version;\n@@ -1064,15 +1064,18 @@ static void show_pack_info(int stat_only)\n \t}\n \n \tif (baseobjects)\n-\t\tprintf(\"non delta: %d object%s\\n\",\n-\t\t       baseobjects, baseobjects > 1 ? \"s\" : \"\");\n+\t\tprintf_ln(Q_(\"non delta: %d object\",\n+\t\t\t     \"non delta: %d objects\",\n+\t\t\t     baseobjects),\n+\t\t\t  baseobjects);\n \tfor (i = 0; i < deepest_delta; i++) {\n \t\tif (!chain_histogram[i])\n \t\t\tcontinue;\n-\t\tprintf(\"chain length = %d: %lu object%s\\n\",\n-\t\t       i + 1,\n-\t\t       chain_histogram[i],\n-\t\t       chain_histogram[i] > 1 ? \"s\" : \"\");\n+\t\tprintf_ln(Q_(\"chain length = %d: %lu object\",\n+\t\t\t     \"chain length = %d: %lu objects\",\n+\t\t\t     chain_histogram[i]),\n+\t\t\t  i + 1,\n+\t\t\t  chain_histogram[i]);\n \t}\n }\n \n@@ -1095,7 +1098,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \treset_pack_idx_option(&opts);\n \tgit_config(git_index_pack_config, &opts);\n \tif (prefix && chdir(prefix))\n-\t\tdie(\"Cannot come back to cwd\");\n+\t\tdie(_(\"Cannot come back to cwd\"));\n \n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n@@ -1128,10 +1131,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\thdr->hdr_signature = htonl(PACK_SIGNATURE);\n \t\t\t\thdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));\n \t\t\t\tif (*c != ',')\n-\t\t\t\t\tdie(\"bad %s\", arg);\n+\t\t\t\t\tdie(_(\"bad %s\"), arg);\n \t\t\t\thdr->hdr_entries = htonl(strtoul(c + 1, &c, 10));\n \t\t\t\tif (*c)\n-\t\t\t\t\tdie(\"bad %s\", arg);\n+\t\t\t\t\tdie(_(\"bad %s\"), arg);\n \t\t\t\tinput_len = sizeof(*hdr);\n \t\t\t} else if (!strcmp(arg, \"-v\")) {\n \t\t\t\tverbose = 1;\n@@ -1143,11 +1146,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\tchar *c;\n \t\t\t\topts.version = strtoul(arg + 16, &c, 10);\n \t\t\t\tif (opts.version > 2)\n-\t\t\t\t\tdie(\"bad %s\", arg);\n+\t\t\t\t\tdie(_(\"bad %s\"), arg);\n \t\t\t\tif (*c == ',')\n \t\t\t\t\topts.off32_limit = strtoul(c+1, &c, 0);\n \t\t\t\tif (*c || opts.off32_limit & 0x80000000)\n-\t\t\t\t\tdie(\"bad %s\", arg);\n+\t\t\t\t\tdie(_(\"bad %s\"), arg);\n \t\t\t} else\n \t\t\t\tusage(index_pack_usage);\n \t\t\tcontinue;\n@@ -1161,11 +1164,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \tif (!pack_name && !from_stdin)\n \t\tusage(index_pack_usage);\n \tif (fix_thin_pack && !from_stdin)\n-\t\tdie(\"--fix-thin cannot be used without --stdin\");\n+\t\tdie(_(\"--fix-thin cannot be used without --stdin\"));\n \tif (!index_name && pack_name) {\n \t\tint len = strlen(pack_name);\n \t\tif (!has_extension(pack_name, \".pack\"))\n-\t\t\tdie(\"packfile name '%s' does not end with '.pack'\",\n+\t\t\tdie(_(\"packfile name '%s' does not end with '.pack'\"),\n \t\t\t    pack_name);\n \t\tindex_name_buf = xmalloc(len);\n \t\tmemcpy(index_name_buf, pack_name, len - 5);\n@@ -1175,7 +1178,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \tif (keep_msg && !keep_name && pack_name) {\n \t\tint len = strlen(pack_name);\n \t\tif (!has_extension(pack_name, \".pack\"))\n-\t\t\tdie(\"packfile name '%s' does not end with '.pack'\",\n+\t\t\tdie(_(\"packfile name '%s' does not end with '.pack'\"),\n \t\t\t    pack_name);\n \t\tkeep_name_buf = xmalloc(len);\n \t\tmemcpy(keep_name_buf, pack_name, len - 5);\n@@ -1184,7 +1187,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t}\n \tif (verify) {\n \t\tif (!index_name)\n-\t\t\tdie(\"--verify with no packfile name given\");\n+\t\t\tdie(_(\"--verify with no packfile name given\"));\n \t\tread_idx_option(&opts, index_name);\n \t\topts.flags |= WRITE_IDX_VERIFY | WRITE_IDX_STRICT;\n \t}\n@@ -1208,7 +1211,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\tint nr_unresolved = nr_deltas - nr_resolved_deltas;\n \t\t\tint nr_objects_initial = nr_objects;\n \t\t\tif (nr_unresolved <= 0)\n-\t\t\t\tdie(\"confusion beyond insanity\");\n+\t\t\t\tdie(_(\"confusion beyond insanity\"));\n \t\t\tobjects = xrealloc(objects,\n \t\t\t\t\t   (nr_objects + nr_unresolved + 1)\n \t\t\t\t\t   * sizeof(*objects));\n@@ -1227,7 +1230,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\t    \"(disk corruption?)\", curr_pack);\n \t\t}\n \t\tif (nr_deltas != nr_resolved_deltas)\n-\t\t\tdie(\"pack has %d unresolved deltas\",\n+\t\t\tdie(_(\"pack has %d unresolved deltas\"),\n \t\t\t    nr_deltas - nr_resolved_deltas);\n \t}\n \tfree(deltas);\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189403","messageId":"1334580603-11577-12-git-send-email-pclouds@gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"[PATCH i18n 11/11] i18n: bundle: mark strings for translation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-16T12:50:03Z","receivedAt":"2012-04-16T12:50:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"---\n bundle.c |   38 +++++++++++++++++++++-----------------\n 1 files changed, 21 insertions(+), 17 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex d9cfd90..6d21c77 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -33,7 +33,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,\n \tif (strbuf_getwholeline_fd(&buf, fd, '\\n') ||\n \t    strcmp(buf.buf, bundle_signature)) {\n \t\tif (report_path)\n-\t\t\terror(\"'%s' does not look like a v2 bundle file\",\n+\t\t\terror(_(\"'%s' does not look like a v2 bundle file\"),\n \t\t\t      report_path);\n \t\tstatus = -1;\n \t\tgoto abort;\n@@ -60,7 +60,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,\n \t\t    (40 <= buf.len && !isspace(buf.buf[40])) ||\n \t\t    (!is_prereq && buf.len <= 40)) {\n \t\t\tif (report_path)\n-\t\t\t\terror(\"unrecognized header: %s%s (%d)\",\n+\t\t\t\terror(_(\"unrecognized header: %s%s (%d)\"),\n \t\t\t\t      (is_prereq ? \"-\" : \"\"), buf.buf, (int)buf.len);\n \t\t\tstatus = -1;\n \t\t\tbreak;\n@@ -86,7 +86,7 @@ int read_bundle_header(const char *path, struct bundle_header *header)\n \tint fd = open(path, O_RDONLY);\n \n \tif (fd < 0)\n-\t\treturn error(\"could not open '%s'\", path);\n+\t\treturn error(_(\"could not open '%s'\"), path);\n \treturn parse_bundle_header(fd, header, path);\n }\n \n@@ -137,7 +137,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \tstruct object_array refs;\n \tstruct commit *commit;\n \tint i, ret = 0, req_nr;\n-\tconst char *message = \"Repository lacks these prerequisite commits:\";\n+\tconst char *message = _(\"Repository lacks these prerequisite commits:\");\n \n \tinit_revisions(&revs, NULL);\n \tfor (i = 0; i < p->nr; i++) {\n@@ -161,7 +161,7 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \trevs.leak_pending = 1;\n \n \tif (prepare_revision_walk(&revs))\n-\t\tdie(\"revision walk setup failed\");\n+\t\tdie(_(\"revision walk setup failed\"));\n \n \ti = req_nr;\n \twhile (i && (commit = get_revision(&revs)))\n@@ -183,12 +183,16 @@ int verify_bundle(struct bundle_header *header, int verbose)\n \t\tstruct ref_list *r;\n \n \t\tr = &header->references;\n-\t\tprintf(\"The bundle contains %d ref%s\\n\",\n-\t\t       r->nr, (1 < r->nr) ? \"s\" : \"\");\n+\t\tprintf_ln(Q_(\"The bundle contains %d ref\",\n+\t\t\t     \"The bundle contains %d refs\",\n+\t\t\t     r->nr),\n+\t\t\t  r->nr);\n \t\tlist_refs(r, 0, NULL);\n \t\tr = &header->prerequisites;\n-\t\tprintf(\"The bundle requires these %d ref%s\\n\",\n-\t\t       r->nr, (1 < r->nr) ? \"s\" : \"\");\n+\t\tprintf_ln(Q_(\"The bundle requires this ref\",\n+\t\t\t     \"The bundle requires these %d refs\",\n+\t\t\t     r->nr),\n+\t\t\t  r->nr);\n \t\tlist_refs(r, 0, NULL);\n \t}\n \treturn ret;\n@@ -283,13 +287,13 @@ int create_bundle(struct bundle_header *header, const char *path,\n \tstrbuf_release(&buf);\n \tfclose(rls_fout);\n \tif (finish_command(&rls))\n-\t\treturn error(\"rev-list died\");\n+\t\treturn error(_(\"rev-list died\"));\n \n \t/* write references */\n \targc = setup_revisions(argc, argv, &revs, NULL);\n \n \tif (argc > 1)\n-\t\treturn error(\"unrecognized argument: %s'\", argv[1]);\n+\t\treturn error(_(\"unrecognized argument: %s'\"), argv[1]);\n \n \tobject_array_remove_duplicates(&revs.pending);\n \n@@ -324,7 +328,7 @@ int create_bundle(struct bundle_header *header, const char *path,\n \t\t * constraints.\n \t\t */\n \t\tif (!(e->item->flags & SHOWN) && e->item->type == OBJ_COMMIT) {\n-\t\t\twarning(\"ref '%s' is excluded by the rev-list options\",\n+\t\t\twarning(_(\"ref '%s' is excluded by the rev-list options\"),\n \t\t\t\te->name);\n \t\t\tfree(ref);\n \t\t\tcontinue;\n@@ -369,7 +373,7 @@ int create_bundle(struct bundle_header *header, const char *path,\n \t\tfree(ref);\n \t}\n \tif (!ref_count)\n-\t\tdie (\"Refusing to create empty bundle.\");\n+\t\tdie(_(\"Refusing to create empty bundle.\"));\n \n \t/* end header */\n \twrite_or_die(bundle_fd, \"\\n\", 1);\n@@ -387,7 +391,7 @@ int create_bundle(struct bundle_header *header, const char *path,\n \trls.out = bundle_fd;\n \trls.git_cmd = 1;\n \tif (start_command(&rls))\n-\t\treturn error(\"Could not spawn pack-objects\");\n+\t\treturn error(_(\"Could not spawn pack-objects\"));\n \n \t/*\n \t * start_command closed bundle_fd if it was > 1\n@@ -405,10 +409,10 @@ int create_bundle(struct bundle_header *header, const char *path,\n \t}\n \tclose(rls.in);\n \tif (finish_command(&rls))\n-\t\treturn error (\"pack-objects died\");\n+\t\treturn error(_(\"pack-objects died\"));\n \tif (!bundle_to_stdout) {\n \t\tif (commit_lock_file(&lock))\n-\t\t\tdie_errno(\"cannot create '%s'\", path);\n+\t\t\tdie_errno(_(\"cannot create '%s'\"), path);\n \t}\n \treturn 0;\n }\n@@ -430,6 +434,6 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)\n \tip.no_stdout = 1;\n \tip.git_cmd = 1;\n \tif (run_command(&ip))\n-\t\treturn error(\"index-pack died\");\n+\t\treturn error(_(\"index-pack died\"));\n \treturn 0;\n }\n-- \n1.7.3.1.256.g2539c.dirty\n"},{"id":"189437","messageId":"20120416172654.GU5813@burratino","threadId":"30259","inReplyTo":"1334580603-11577-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH i18n 01/11] Add three convenient format printing functions with \\n automatically appended","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T17:26:54Z","receivedAt":"2012-04-16T17:26:54Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n>     printf(\"hello world\\n\");\n>\n> can be converted to\n>\n>     printf_ln(_(\"hello world\"));\n\nFun.\n\n[...]\n> --- a/strbuf.c\n> +++ b/strbuf.c\n> @@ -464,3 +464,36 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,\n[...]\n> +int printf_ln(const char *fmt, ...)\n> +{\n> +\tint ret;\n> +\tva_list ap;\n> +\tva_start(ap, fmt);\n> +\tret = vprintf(fmt, ap);\n> +\tva_end(ap);\n> +\tif (ret >= 0)\n> +\t\tret += printf(\"\\n\");\n\nWhat happens if the second printf fails?\n"},{"id":"189442","messageId":"20120416175402.GV5813@burratino","threadId":"30259","inReplyTo":"1334580603-11577-4-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T17:54:02Z","receivedAt":"2012-04-16T17:54:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi again,\n\nNguyễn Thái Ngọc Duy wrote:\n\n> --- a/parse-options.c\n> +++ b/parse-options.c\n> @@ -490,7 +490,7 @@ static int usage_argh(const struct option *opts, FILE *outfile)\n\nThe interesting parts in this patch are strings not marked for\ntranslation:\n\n>  \t\t\ts = literal ? \"[%s]\" : \"[<%s>]\";\n>  \telse\n>  \t\ts = literal ? \" %s\" : \" <%s>\";\n\nThat means the usage message will have one of the formats\n\n\t--foo[=<bar>]\n\t-f[<bar>]\n\t--foo <bar>\n\t-f <bar>\n\nin all languages.  Makes sense.\n\n> -\treturn fprintf(outfile, s, opts->argh ? opts->argh : \"...\");\n> +\treturn fprintf(outfile, s, opts->argh ? _(opts->argh) : \"...\");\n\n\"bar\" becomes \"...\" in all languages when the caller was too lazy to\nfill it in.  I wonder if we should not just require argh to be\nnon-NULL for options that can take an argument and catch mistakes in\nparse_options_check().\n\n> @@ -508,13 +508,12 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n>  \tif (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)\n>  \t\tfprintf(outfile, \"cat <<\\\\EOF\\n\");\n>  \n> -\tfprintf(outfile, \"usage: %s\\n\",\n> +\tfprintf_ln(outfile, _(\"usage: %s\"),\n\nIt's too bad this doesn't share code with usage.c. :)  The prompt will\nbe translated in some contexts and not in others, which seems fine.\n\n> -                                   *usagestr++);\n> +                                   _(*usagestr++));\n\nMaybe this change belongs in a separate patch that would mark the\nusage strings with N_ at the same time. (*)\n\n>  \twhile (*usagestr && **usagestr)\n> -\t\tfprintf(outfile, \"   or: %s\\n\", *usagestr++);\n> +\t\tfprintf_ln(outfile, _(\"   or: %s\"), _(*usagestr++));\n\nMaybe worth a translators note to explain how these line up.\n\n>  \twhile (*usagestr) {\n> -\t\tfprintf(outfile, \"%s%s\\n\",\n> -\t\t\t\t**usagestr ? \"    \" : \"\",\n> -\t\t\t\t*usagestr);\n> +\t\tfprintf(outfile, \"%s%s\\n\", **usagestr ? \"    \" : \"\",\n> +\t\t\t_(*usagestr));\n\nMph, the space is going to look wrong in other languages.\n\n>  \t\tusagestr++;\n>  \t}\n>  \n> @@ -528,7 +527,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n>  \t\tif (opts->type == OPTION_GROUP) {\n>  \t\t\tfputc('\\n', outfile);\n>  \t\t\tif (*opts->help)\n> -\t\t\t\tfprintf(outfile, \"%s\\n\", opts->help);\n> +\t\t\t\tfprintf(outfile, \"%s\\n\", _(opts->help));\n[...]\n> @@ -558,7 +557,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n>  \t\t\tfputc('\\n', outfile);\n>  \t\t\tpad = USAGE_OPTS_WIDTH;\n>  \t\t}\n> -\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\", opts->help);\n> +\t\tfprintf(outfile, \"%*s%s\\n\", pad + USAGE_GAP, \"\", _(opts->help));\n[...]\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -66,12 +66,14 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,\n>   *\n>   * `argh`::\n>   *   token to explain the kind of argument this option wants. Keep it\n> - *   homogeneous across the repository.\n> + *   homogeneous across the repository. Should be wrapped by N_() for\n> + *   translation.\n>   *\n>   * `help`::\n>   *   the short help associated to what the option does.\n>   *   Must never be NULL (except for OPTION_END).\n>   *   OPTION_GROUP uses this pointer to store the group header.\n> + *   Should be wrapped by N_() for translation.\n[...]\n> @@ -158,7 +160,8 @@ struct option {\n>  #define OPT_BOOLEAN OPT_COUNTUP\n>  \n>  /* parse_options() will filter out the processed options and leave the\n> - * non-option arguments in argv[].\n> + * non-option arguments in argv[]. usagestr strings should be marked\n> + * for translation with N_().\n\nAlso might be worth splitting into a separate patch that adjusts\ncallers to use N_ at the same time.  Is there some easy way to catch\nstrings not in the po template that are passed to gettext() using a\nvariable (at runtime)?\n\nThanks for some food for thought.\nJonathan\n"},{"id":"189492","messageId":"20120416233514.GX12613@burratino","threadId":"30259","inReplyTo":"20120416175402.GV5813@burratino","subject":"Re: [PATCH i18n 03/11] i18n: parseopt: lookup help and argument translations when showing usage","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-16T23:35:14Z","receivedAt":"2012-04-16T23:35:14Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jonathan Nieder wrote:\n> Nguyễn Thái Ngọc Duy wrote:\n\n>> -                                   *usagestr++);\n>> +                                   _(*usagestr++));\n>\n> Maybe this change belongs in a separate patch that would mark the\n> usage strings with N_ at the same time. (*)\n\nI missed that you took care of many of these (e.g., for \"git apply\")\nlater in the series.  I wonder if coccinelle could be used to make\nthe change everywhere at once.\n\n[...]\n>                                      Is there some easy way to catch\n> strings not in the po template that are passed to gettext() using a\n> variable (at runtime)?\n\nIf doing that, this kind of sanity check would help catch stragglers.\n\nJonathan\n"},{"id":"189510","messageId":"CABPQNSbnGKFW=Lf0nnLEOAZf4iOGsmfiMqoioitH3Ps6ZWV7FA@mail.gmail.com","threadId":"30259","inReplyTo":"1334580603-11577-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH i18n 01/11] Add three convenient format printing functions with \\n automatically appended","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-04-17T08:12:20Z","receivedAt":"2012-04-17T08:12:20Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"2012/4/16 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:\n> +int printf_ln(const char *fmt, ...)\n> +{\n> +       int ret;\n> +       va_list ap;\n> +       va_start(ap, fmt);\n> +       ret = vprintf(fmt, ap);\n> +       va_end(ap);\n> +       if (ret >= 0)\n> +               ret += printf(\"\\n\");\n<snip>\n> +               ret += fprintf(fp, \"\\n\");\n\nApart from Jonathan's comment, isn't [f]printf a big hammer for this?\nWouldn't putchar / fputc be a tad more light-weight (and perhaps\nclearer)?\n"},{"id":"189647","messageId":"20120418193006.GA30361@burratino","threadId":"30259","inReplyTo":"1334580603-11577-6-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH i18n 05/11] i18n: help: mark strings for translation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-18T19:30:28Z","receivedAt":"2012-04-18T19:30:28Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> This patch also marks most common commands' synopsis for translation\n> so that \"git help\" gives a friendly listing.\n[...]\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2282,7 +2282,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n>  \t--keyword=_ --keyword=N_ --keyword=\"Q_:1,2\"\n>  XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell\n>  XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl\n> -LOCALIZED_C := $(C_OBJ:o=c)\n> +LOCALIZED_C := $(C_OBJ:o=c) common-cmds.h\n\nLOCALIZED_C probably ought to include\n\n\t$(LIB_H) branch.h bundle.h bisect.h fetch-pack.h thread-utils.h\n\tsend-pack.h shortlog.h reachable.h wt-status.h tar.h url.h walker.h\n\t$(XDIFF_H) $(VCSSVN_H)\n\ntoo, just in case.  This would involve moving the definitions of\nXDIFF_H and VCSSVN_H out of the ifndef USE_COMPUTED_HEADER_DEPENDENCIES\nblock.\n\nSorry I missed this before.\n\n[...]\n> +++ b/git.c\n[...]\n> @@ -389,6 +397,6 @@ const char *help_unknown_cmd(const char *cmd)\n>  \n>  int cmd_version(int argc, const char **argv, const char *prefix)\n>  {\n> -\tprintf(\"git version %s\\n\", git_version_string);\n> +\tprintf_ln(_(\"git version %s\"), git_version_string);\n>  \treturn 0;\n\nAn odd one.  I think it's probably best to leave it untranslated for\nthe sake of i18n-unaware scripts. :(\n\nThanks,\nJonathan\n"},{"id":"189650","messageId":"20120418194021.GB30361@burratino","threadId":"30259","inReplyTo":"1334580603-11577-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH i18n 00/11] Mark more strings for translation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-18T19:40:21Z","receivedAt":"2012-04-18T19:40:21Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nNguyễn Thái Ngọc Duy wrote:\n\n> This series marks the following for translations\n>\n>  - relative dates\n>  - git-help (and provide support for translating parseopt)\n>  - git-remote\n>  - git-index-pack\n>  - git-apply\n>  - git-bundle\n>\n> Except git-help, other commands are chosen because they handle plural\n> form and I'd like to reuse gettext for that. There are a few conflicts\n> with topics on pu, but seem easy to resolve.\n\nMy main reaction is that it would be nice to find a way to check that\nparseopt users correctly mark their messages for translation while we\nremember.  But that doesn't need to block the series.  Ideas about\nmechanism from gettext wizards welcome.\n\nOther comments inline.  I expect that there will be at least one\nreroll before this is ready.\n\nThanks,\nJonathan\n"},{"id":"189825","messageId":"CACsJy8An8qsR=T8f4ouS8FMut4Z+NOTy5w_pdzjYVyPJ8AEDyg@mail.gmail.com","threadId":"30259","inReplyTo":"20120418194021.GB30361@burratino","subject":"Re: [PATCH i18n 00/11] Mark more strings for translation","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-22T03:24:44Z","receivedAt":"2012-04-22T03:24:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2012/4/19 Jonathan Nieder <jrnieder@gmail.com>:\n> My main reaction is that it would be nice to find a way to check that\n> parseopt users correctly mark their messages for translation while we\n> remember.  But that doesn't need to block the series.  Ideas about\n> mechanism from gettext wizards welcome.\n\nHow about we use msgen on git.pot to produce all-translated .po file.\nThen gettext(foo) would return foo if the translation is not found\n(i.e. the string not marked). Now I don't know how we force loading\nthis special .mo file..\n-- \nDuy\n"},{"id":"189837","messageId":"4F9434F1.9000900@in.waw.pl","threadId":"30259","inReplyTo":"1334580603-11577-10-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence","fromName":"Zbigniew Jędrzejewski-Szmek","fromEmail":"zbyszek@in.waw.pl","sentAt":"2012-04-22T16:42:25Z","receivedAt":"2012-04-22T16:42:25Z","isPatch":true,"sender":{"key":"zbyszek@in.waw.pl","avatar":"https://avatars.githubusercontent.com/u/349618?v=4"},"body":"On 04/16/2012 02:50 PM, Nguyễn Thái Ngọc Duy wrote:\n> ---\n>  builtin/apply.c |   33 +++++++++++++++++++--------------\n>  1 files changed, 19 insertions(+), 14 deletions(-)\n> \n> diff --git a/builtin/apply.c b/builtin/apply.c\n> index 6e9a02e..87922cf 100644\n> --- a/builtin/apply.c\n> +++ b/builtin/apply.c\n> @@ -335,22 +335,25 @@ static void clear_image(struct image *image)\n>  \timage->len = 0;\n>  }\n>  \n> -static void say_patch_name(FILE *output, const char *pre,\n> -\t\t\t   struct patch *patch, const char *post)\n> +/* fmt must contain _one_ %s and no other substitution */\n> +static void say_patch_name(FILE *output, struct patch *patch, const char *fmt)\n>  {\n> -\tfputs(pre, output);\n> +\tstruct strbuf sb = STRBUF_INIT;\n> +\n>  \tif (patch->old_name && patch->new_name &&\n>  \t    strcmp(patch->old_name, patch->new_name)) {\n> -\t\tquote_c_style(patch->old_name, NULL, output, 0);\n> -\t\tfputs(\" => \", output);\n> -\t\tquote_c_style(patch->new_name, NULL, output, 0);\n> +\t\tquote_c_style(patch->old_name, &sb, NULL, 0);\n> +\t\tstrbuf_addstr(&sb, \" => \");\n> +\t\tquote_c_style(patch->new_name, &sb, NULL, 0);\n>  \t} else {\n>  \t\tconst char *n = patch->new_name;\n>  \t\tif (!n)\n>  \t\t\tn = patch->old_name;\n> -\t\tquote_c_style(n, NULL, output, 0);\n> +\t\tquote_c_style(n, &sb, NULL, 0);\n>  \t}\n> -\tfputs(post, output);\n> +\tfprintf(output, fmt, sb.buf);\n> +\tfprintf(output, \"\\n\");\n> +\tstrbuf_release(&sb);\n>  }\n>  \n>  #define CHUNKSIZE (8192)\n> @@ -3165,8 +3168,8 @@ static int check_patch_list(struct patch *patch)\n>  \tprepare_fn_table(patch);\n>  \twhile (patch) {\n>  \t\tif (apply_verbosely)\n> -\t\t\tsay_patch_name(stderr,\n> -\t\t\t\t       \"Checking patch \", patch, \"...\\n\");\n> +\t\t\tsay_patch_name(stderr, patch,\n> +\t\t\t\t       _(\"Checking patch %s...\"));\n>  \t\terr |= check_patch(patch);\n>  \t\tpatch = patch->next;\n>  \t}\n> @@ -3530,6 +3533,7 @@ static int write_out_one_reject(struct patch *patch)\n>  \tchar namebuf[PATH_MAX];\n>  \tstruct fragment *frag;\n>  \tint cnt = 0;\n> +\tstruct strbuf sb = STRBUF_INIT;\n>  \n>  \tfor (cnt = 0, frag = patch->fragments; frag; frag = frag->next) {\n>  \t\tif (!frag->rejected)\n> @@ -3539,8 +3543,8 @@ static int write_out_one_reject(struct patch *patch)\n>  \n>  \tif (!cnt) {\n>  \t\tif (apply_verbosely)\n> -\t\t\tsay_patch_name(stderr,\n> -\t\t\t\t       \"Applied patch \", patch, \" cleanly.\\n\");\n> +\t\t\tsay_patch_name(stderr, patch,\n> +\t\t\t\t       _(\"Applied patch %s cleanly.\"));\n>  \t\treturn 0;\n>  \t}\n>  \n> @@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)\n>  \t\tdie(_(\"internal error\"));\n>  \n>  \t/* Say this even without --verbose */\n> -\tsay_patch_name(stderr, \"Applying patch \", patch, \" with\");\n> -\tfprintf(stderr, \" %d rejects...\\n\", cnt);\n> +\tstrbuf_addf(&sb, _(\"Applying patch %%s with %d rejects...\"), cnt);\nShouldn't this part be:\n        strbuf_addf(&sb, Q_(\"Applying patch %%s with one reject...\",\n                            \"Applying patch %%s with %d rejects...\",\n                            cnt), cnt);\n?\n\n-\nZbyszek\n"},{"id":"189861","messageId":"CACsJy8AQtsmC65SXXjR_=e5T+LF=WYHPFMvK5EUcV_ZYKQuOag@mail.gmail.com","threadId":"30259","inReplyTo":"4F9434F1.9000900@in.waw.pl","subject":"Re: [PATCH i18n 09/11] i18n: apply: update say_patch_name to give translators complete sentence","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-04-23T11:33:22Z","receivedAt":"2012-04-23T11:33:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Apr 22, 2012 at 11:42 PM, Zbigniew Jędrzejewski-Szmek\n<zbyszek@in.waw.pl> wrote:\n> On 04/16/2012 02:50 PM, Nguyễn Thái Ngọc Duy wrote:\n>> @@ -3551,8 +3555,9 @@ static int write_out_one_reject(struct patch *patch)\n>>               die(_(\"internal error\"));\n>>\n>>       /* Say this even without --verbose */\n>> -     say_patch_name(stderr, \"Applying patch \", patch, \" with\");\n>> -     fprintf(stderr, \" %d rejects...\\n\", cnt);\n>> +     strbuf_addf(&sb, _(\"Applying patch %%s with %d rejects...\"), cnt);\n> Shouldn't this part be:\n>        strbuf_addf(&sb, Q_(\"Applying patch %%s with one reject...\",\n>                            \"Applying patch %%s with %d rejects...\",\n>                            cnt), cnt);\n> ?\n\nYes. Thanks for catching.\n-- \nDuy\n"}]}