git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð" <avarab@gmail.com>,
	"Jiang Xin" <worldhello.net@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 3/5] i18n: parseopt: lookup help and argument translations when showing usage
Date: Thu,  8 Mar 2012 16:16:36 +0700	[thread overview]
Message-ID: <1331198198-22409-4-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1331198198-22409-1-git-send-email-pclouds@gmail.com>

"struct option" and the help usage array needs N_() marking on help
and argument text for this to work.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 850cfa7..6247c20 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -490,7 +490,7 @@ static int usage_argh(const struct option *opts, FILE *outfile)
 			s = literal ? "[%s]" : "[<%s>]";
 	else
 		s = literal ? " %s" : " <%s>";
-	return fprintf(outfile, s, opts->argh ? opts->argh : "...");
+	return fprintf(outfile, s, opts->argh ? gettext(opts->argh) : "...");
 }
 
 #define USAGE_OPTS_WIDTH 24
@@ -508,13 +508,12 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 	if (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)
 		fprintf(outfile, "cat <<\\EOF\n");
 
-	fprintf(outfile, "usage: %s\n", *usagestr++);
+	fprintf(outfile, _("usage: %s\n"), gettext(*usagestr++));
 	while (*usagestr && **usagestr)
-		fprintf(outfile, "   or: %s\n", *usagestr++);
+		fprintf(outfile, _("   or: %s\n"), gettext(*usagestr++));
 	while (*usagestr) {
-		fprintf(outfile, "%s%s\n",
-				**usagestr ? "    " : "",
-				*usagestr);
+		fprintf(outfile, "%s%s\n", **usagestr ? "    " : "",
+			gettext(*usagestr));
 		usagestr++;
 	}
 
@@ -528,7 +527,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 		if (opts->type == OPTION_GROUP) {
 			fputc('\n', outfile);
 			if (*opts->help)
-				fprintf(outfile, "%s\n", opts->help);
+				fprintf(outfile, "%s\n", gettext(opts->help));
 			continue;
 		}
 		if (!full && (opts->flags & PARSE_OPT_HIDDEN))
@@ -558,7 +557,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
 			fputc('\n', outfile);
 			pad = USAGE_OPTS_WIDTH;
 		}
-		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+		fprintf(outfile, "%*s%s\n", pad + USAGE_GAP, "", gettext(opts->help));
 	}
 	fputc('\n', outfile);
 
-- 
1.7.3.1.256.g2539c.dirty

  parent reply	other threads:[~2012-03-08  9:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08  9:16 [PATCH 0/5] i18n-ize relative dates, git-help and parseopt Nguyễn Thái Ngọc Duy
2012-03-08  9:16 ` [PATCH 1/5] i18n: keep the last \n even when text is poisoned Nguyễn Thái Ngọc Duy
2012-03-08 22:01   ` Jonathan Nieder
2012-03-09  1:11     ` Nguyen Thai Ngoc Duy
2012-03-09  2:33       ` Nguyen Thai Ngoc Duy
2012-03-09 11:24     ` Ævar Arnfjörð Bjarmason
2012-03-08  9:16 ` [PATCH 2/5] i18n: mark relative dates for translation Nguyễn Thái Ngọc Duy
2012-03-15 18:51   ` Jonathan Nieder
2012-03-15 19:16     ` Johannes Sixt
2012-03-15 19:18       ` Jonathan Nieder
2012-03-16 11:47     ` Nguyen Thai Ngoc Duy
2012-03-08  9:16 ` Nguyễn Thái Ngọc Duy [this message]
2012-03-08 22:07   ` [PATCH 3/5] i18n: parseopt: lookup help and argument translations when showing usage Jonathan Nieder
2012-03-08  9:16 ` [PATCH 4/5] i18n: help: mark parseopt strings for translation Nguyễn Thái Ngọc Duy
2012-03-08  9:16 ` [PATCH 5/5] i18n: help: mark " Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331198198-22409-4-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=worldhello.net@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).