git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i18n: move the trailing space out of translatable strings
@ 2013-12-08  2:11 Nguyễn Thái Ngọc Duy
  2013-12-08  2:15 ` Duy Nguyen
  2013-12-09 19:46 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2013-12-08  2:11 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

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 <pclouds@gmail.com>
---
 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

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

* Re: [PATCH] i18n: move the trailing space out of translatable strings
  2013-12-08  2:11 [PATCH] i18n: move the trailing space out of translatable strings Nguyễn Thái Ngọc Duy
@ 2013-12-08  2:15 ` Duy Nguyen
  2013-12-08  3:56   ` Keshav Kini
  2013-12-09 19:46 ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Duy Nguyen @ 2013-12-08  2:15 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Nguyễn Thái Ngọc Duy

On Sun, Dec 8, 2013 at 9:11 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> 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.

And I just realized spaces are more common in languages using latin
alphabet but are not a rule. CJK languages do not have/need spaces so
this might be a wrong move..
-- 
Duy

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

* Re: [PATCH] i18n: move the trailing space out of translatable strings
  2013-12-08  2:15 ` Duy Nguyen
@ 2013-12-08  3:56   ` Keshav Kini
  0 siblings, 0 replies; 4+ messages in thread
From: Keshav Kini @ 2013-12-08  3:56 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List

The following message is a courtesy copy of an article
that has been posted to gmane.comp.version-control.git as well.

Duy Nguyen <pclouds@gmail.com> writes:
> On Sun, Dec 8, 2013 at 9:11 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> 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.
>
> And I just realized spaces are more common in languages using latin
> alphabet but are not a rule. CJK languages do not have/need spaces so
> this might be a wrong move..

There are already other issues as well.  The strings also seem to be
assuming certain word orders.  For example:

> -					on_what = _("HEAD detached at ");
> +					on_what = _("HEAD detached at");

Both versions of this assume that the location at which HEAD was
detached should come at the end of the sentence, whereas in
rightward-headed languages such as Japanese it would be more natural to
put the location at the middle or beginning of the sentence (while it is
possible to rewrite the text a bit to force the location to come at the
end).

I think the best practice is to just have one long string per "message"
the program is supposed to display, and only display that string with %s
substituted for data, rather than printing that string and then printing
the data, or printing the data and then printing the string, or
whatever.  With printf() in C, the %s can even be reordered wrt to the
calling order with a special syntax, "%m$", if necessary, as I just
learned from `man 3 printf`...

-Keshav

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

* Re: [PATCH] i18n: move the trailing space out of translatable strings
  2013-12-08  2:11 [PATCH] i18n: move the trailing space out of translatable strings Nguyễn Thái Ngọc Duy
  2013-12-08  2:15 ` Duy Nguyen
@ 2013-12-09 19:46 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2013-12-09 19:46 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> 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"...

Not really.  Only if one guesses (or knows) that Vietnamese is among
the languages that use SP to separate words.  There are languages
that do not use inter-word spaces.

Because those languages are in the minority, it would be easier to
unconditionally add SP after translatable string regardless of the
l10n target languages, but I am afraid that it is going in a wrong
direction in the longer term.

>  		clean_print_color(CLEAN_COLOR_PROMPT);
> -		printf(_("Input ignore patterns>> "));
> +		printf("%s ", _("Input ignore patterns>>"));
>  		clean_print_color(CLEAN_COLOR_RESET);

As this space after the prompt may be different from inter-word
space after all, this one may probably be on the borderline.

> @@ -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(' ');

As is this change.

But it is an example that can be used to illustrate my earlier
point.  The l10n target language may want to have _no_ space between
words, i.e. to turn the above into:

	printf("%sを削除しますか?", qname);
        putchar(' ');

i.e. no space between the object of the verb ("the path being
removed") and the verb ("to remove"), while still wanting to have SP
between the prompt and its answer like everybody else.  And having
SP after "remove" in the gettext key _is_ a good thing, as l10n
people can choose not to have any SP between the verb and its
object.

> 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"));

But I think that this changes enforces the inter-word SP policy that
could go against convention by specific l10n target languages.

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

end of thread, other threads:[~2013-12-09 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-08  2:11 [PATCH] i18n: move the trailing space out of translatable strings Nguyễn Thái Ngọc Duy
2013-12-08  2:15 ` Duy Nguyen
2013-12-08  3:56   ` Keshav Kini
2013-12-09 19:46 ` Junio C Hamano

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 NNTP newsgroup(s).