Skip to contentSkip to conversation

transport.c: mark push status strings for translation

PATCH/RESEND Nguyễn Thái Ngọc Duy 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Mark strings like "[up to date]" passed to print_ref_status() for translation with N_() instead of _() so they can remain untranslated in porcelain mode.

While at there, mark some error strings in git push for translation too.

---
 builtin/push.c |  8 +++---
 transport.c    | 81 ++++++++++++++++++++++++++++++++++------------------------
 2 files changed, 52 insertions(+), 37 deletions(-)
builtin/push.c +4 -4
index 7b1b66c..22e2d4c 100644
@@ -319,7 +319,7 @@ static int push_with_options(struct transport *transport, int flags)
 
 	if (!is_empty_cas(&cas)) {
 		if (!transport->smart_options)
-			die("underlying transport does not support --%s option",
+			die(_("underlying transport does not support --%s option"),
 			    CAS_OPT_NAME);
 		transport->smart_options->cas = &cas;
 	}
@@ -426,7 +426,7 @@ static int option_parse_recurse_submodules(const struct option *opt,
 
 	if (*flags & (TRANSPORT_RECURSE_SUBMODULES_CHECK |
 		      TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND))
-		die("%s can only be used once.", opt->long_name);
+		die(_("%s can only be used once."), opt->long_name);
 
 	if (arg) {
 		if (!strcmp(arg, "check"))
@@ -434,9 +434,9 @@ static int option_parse_recurse_submodules(const struct option *opt,
 		else if (!strcmp(arg, "on-demand"))
 			*flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
 		else
-			die("bad %s argument: %s", opt->long_name, arg);
+			die(_("bad %s argument: %s"), opt->long_name, arg);
 	} else
-		die("option %s needs an argument (check|on-demand)",
+		die(_("option %s needs an argument (check|on-demand)"),
 				opt->long_name);
 
 	return 0;
transport.c +48 -33

138 lines not on this page · raw message

Signature · 1 line
1.8.2.83.gc99314b
#1 lore raw
Quoted 3 lines · Nguyễn Thái Ngọc Duy

Mark strings like "[up to date]" passed to print_ref_status() for translation with N_() instead of _() so they can remain untranslated in porcelain mode.

Makes sense.

[...]

builtin/push.c

Quoted 2 lines
builtin/push.c +0 -0

Perhaps it would make sense to send these as a separate patch, since they are simpler than the rest.

[...]

Quoted 11 lines
transport.c +1 -0
@@ -14,6 +14,7 @@
 #include "url.h"
 #include "submodule.h"
 #include "string-list.h"
+#include "utf8.h"
 
 /* rsync support */
 

transport.c static void print_ref_status(char flag, const char *summary, struct ref *to, str · line 632

Quoted 6 lines
transport.c +2 -1
@@ -627,16 +628,23 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
 		else
 			fprintf(stdout, "%s\n", summary);
 	} else {
-		fprintf(stderr, " %c %-*s ", flag, TRANSPORT_SUMMARY_WIDTH, summary);
+		int width = TRANSPORT_SUMMARY_WIDTH;
+		const char *localized_summary = _(summary);

The summary arg comes from one of a few places:

(a) [deleted] etc from print_ok_ref_status, which you marked with N_ (good)

(b) deadbe... from status_abbrev via print_ok_ref_status. Can we avoid passing it to gettext()?

(c) [no match] etc from print_one_push_status, marked with

     N_ (good)

I am tempted to suggest something like

		const char *localized_summary;

		if (*summary != '[')
			/* Leave abbreviated sha1 from status_abbrev() alone */
			localized_summary = summary;
		else
			localized_summary = _(summary);

but that's kind of ugly. Is there a simpler way? Should the summary arg be passed in already localized (with 'porcelain' handling higher up)?

Thanks,
Jonathan