Subject: [PATCH] i18n: move the trailing space out of translatable strings

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Sun, 8 Dec 2013 09:11:44 +0700

I've got this with Vietnamese translation

    $ git status
    HEAD được tách rời từorigin/master

One does not need to understand Vietnamese to see that a space is
missing before "origin/master" and this is because the original string
has a trailing space, but the translated one omits it.

I could fix vi.po alone, but it'd be better to avoid similar mistakes
for all translations by moving the trailing space out of all
translatable strings (*). This is inline with how we handle newlines
(e.g. *printf_ln wrappers) but it's not widespread enough to make new
*printf_space wrappers.

(*) the strings are detected by

    make pot; msgcat --no-wrap po/git.pot|grep 'msgid.* "$'

and if you do it after this patch, you will see maybe 3 matched lines
from git-bisect.sh and git-am.sh that I didn't bother to fix.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 BTW "msgcat...|grep 'msgid.*\n"$'" gives 159 matches. Low hanging
 fruit..

 builtin/clean.c |  5 +++--
 builtin/clone.c |  4 ++--
 wt-status.c     | 26 +++++++++++++-------------
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 615cd57..2b7e694 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -656,7 +656,7 @@ static int filter_by_patterns_cmd(void)
 			pretty_print_dels();
 
 		clean_print_color(CLEAN_COLOR_PROMPT);
-		printf(_("Input ignore patterns>> "));
+		printf("%s ", _("Input ignore patterns>>"));
 		clean_print_color(CLEAN_COLOR_RESET);
 		if (strbuf_getline(&confirm, stdin, '\n') != EOF)
 			strbuf_trim(&confirm);
@@ -754,7 +754,8 @@ static int ask_each_cmd(void)
 		/* Ctrl-D should stop removing files */
 		if (!eof) {
 			qname = quote_path_relative(item->string, NULL, &buf);
-			printf(_("remove %s? "), qname);
+			printf(_("remove %s?"), qname);
+			putchar(' ');
 			if (strbuf_getline(&confirm, stdin, '\n') != EOF) {
 				strbuf_trim(&confirm);
 			} else {
diff --git a/builtin/clone.c b/builtin/clone.c
index 874e0fd..d48ccee 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -551,12 +551,12 @@ static void update_remote_refs(const struct ref *refs,
 
 	if (check_connectivity) {
 		if (transport->progress)
-			fprintf(stderr, _("Checking connectivity... "));
+			fprintf(stderr, _("Checking connectivity..."));
 		if (check_everything_connected_with_transport(iterate_ref_map,
 							      0, &rm, transport))
 			die(_("remote did not send all necessary objects"));
 		if (transport->progress)
-			fprintf(stderr, _("done.\n"));
+			fprintf(stderr, " %s", _("done.\n"));
 	}
 
 	if (refs) {
diff --git a/wt-status.c b/wt-status.c
index 4625cdb..3637656 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -330,11 +330,11 @@ static void wt_status_print_change_data(struct wt_status *s,
 		if (d->new_submodule_commits || d->dirty_submodule) {
 			strbuf_addstr(&extra, " (");
 			if (d->new_submodule_commits)
-				strbuf_addf(&extra, _("new commits, "));
+				strbuf_addf(&extra, "%s, ", _("new commits"));
 			if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
-				strbuf_addf(&extra, _("modified content, "));
+				strbuf_addf(&extra, "%s, ", _("modified content"));
 			if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
-				strbuf_addf(&extra, _("untracked content, "));
+				strbuf_addf(&extra, "%s, ", _("untracked content"));
 			strbuf_setlen(&extra, extra.len - 2);
 			strbuf_addch(&extra, ')');
 		}
@@ -1244,30 +1244,30 @@ void wt_status_print(struct wt_status *s)
 			    s->branch && !strcmp(s->branch, "HEAD"));
 
 	if (s->branch) {
-		const char *on_what = _("On branch ");
+		const char *on_what = _("On branch");
 		const char *branch_name = s->branch;
 		if (!prefixcmp(branch_name, "refs/heads/"))
 			branch_name += 11;
 		else if (!strcmp(branch_name, "HEAD")) {
 			branch_status_color = color(WT_STATUS_NOBRANCH, s);
 			if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
-				on_what = _("rebase in progress; onto ");
+				on_what = _("rebase in progress; onto");
 				branch_name = state.onto;
 			} else if (state.detached_from) {
 				unsigned char sha1[20];
 				branch_name = state.detached_from;
 				if (!get_sha1("HEAD", sha1) &&
 				    !hashcmp(sha1, state.detached_sha1))
-					on_what = _("HEAD detached at ");
+					on_what = _("HEAD detached at");
 				else
-					on_what = _("HEAD detached from ");
+					on_what = _("HEAD detached from");
 			} else {
 				branch_name = "";
 				on_what = _("Not currently on any branch.");
 			}
 		}
 		status_printf(s, color(WT_STATUS_HEADER, s), "");
-		status_printf_more(s, branch_status_color, "%s", on_what);
+		status_printf_more(s, branch_status_color, "%s ", on_what);
 		status_printf_more(s, branch_color, "%s\n", branch_name);
 		if (!s->is_initial)
 			wt_status_print_tracking(s);
@@ -1456,7 +1456,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 
 	branch = branch_get(s->branch + 11);
 	if (s->is_initial)
-		color_fprintf(s->fp, header_color, _("Initial commit on "));
+		color_fprintf(s->fp, header_color, "%s ", _("Initial commit on"));
 
 	color_fprintf(s->fp, branch_color_local, "%s", branch_name);
 
@@ -1488,15 +1488,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
 	if (upstream_is_gone) {
 		color_fprintf(s->fp, header_color, _("gone"));
 	} else if (!num_ours) {
-		color_fprintf(s->fp, header_color, _("behind "));
+		color_fprintf(s->fp, header_color, "%s ", _("behind"));
 		color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
 	} else if (!num_theirs) {
-		color_fprintf(s->fp, header_color, _("ahead "));
+		color_fprintf(s->fp, header_color, "%s ", _("ahead"));
 		color_fprintf(s->fp, branch_color_local, "%d", num_ours);
 	} else {
-		color_fprintf(s->fp, header_color, _("ahead "));
+		color_fprintf(s->fp, header_color, "%s ", _("ahead"));
 		color_fprintf(s->fp, branch_color_local, "%d", num_ours);
-		color_fprintf(s->fp, header_color, _(", behind "));
+		color_fprintf(s->fp, header_color, ", %s ", _("behind"));
 		color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
 	}
 
-- 
1.8.5.1.77.g42c48fa