Re: [PATCH] i18n: Not add stripped contents for translation

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] i18n: Not add stripped contents for translation

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:13

Jiang Xin [off-list ref] writes:
The last two chars of the concatenate str from the i18n marked strings
(", ") will be stripped out by strbuf_setlen.

        before: "new commits, modified content, "
        end:    "new commits, modified content"

If the translations won't end with COMMA+SPACE, will break the integrity
of the concatenate string. As for Chinese, COMMA+SPACE may translated to
"," -- a 3-byte UTF-8 Chinese comma character.
Hmph.  Why would that be a bad thing in the first place?
For example, for the diff.c::print_stat_summary() message, you have this
translation:
 1 个文件被修改,插入 3 行(+),删除 3 行(-)
where the original would be:

   %d file changed, %d insertions(+), %d deletions(-).

and I would imagine that it entirely is plausible if a native reader would
wish to read a Japanese translation like this:

   1個のファイルを変更、挿入 3 行(+)、削除 3 行(-)

without using ASCII comma, but using "、" instead.
quoted hunk
diff --git a/wt-status.c b/wt-status.c
index 9ffc535..0042dbc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -245,11 +245,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, ')');
 		}

Re: [PATCH] i18n: Not add stripped contents for translation

From: Jiang Xin <hidden>
Date: 2016-06-15 22:53:13

2012/3/5 Junio C Hamano [off-list ref]:
quoted
If the translations won't end with COMMA+SPACE, will break the integrity
of the concatenate string. As for Chinese, COMMA+SPACE may translated to
"," -- a 3-byte UTF-8 Chinese comma character.
Hmph.  Why would that be a bad thing in the first place?
Orignal source code:

244   case WT_STATUS_CHANGED:
245     if (d->new_submodule_commits || d->dirty_submodule) {
246       strbuf_addstr(&extra, " (");
247       if (d->new_submodule_commits)
248         strbuf_addf(&extra, _("new commits, "));
249       if (d->dirty_submodule & DIRTY_SUBMODULE_MODIFIED)
250         strbuf_addf(&extra, _("modified content, "));
251       if (d->dirty_submodule & DIRTY_SUBMODULE_UNTRACKED)
252         strbuf_addf(&extra, _("untracked content, "));
253       strbuf_setlen(&extra, extra.len - 2);
254       strbuf_addch(&extra, ')');
255     }

The bad thing is strbuf_setlen() at line 253. We can not asume the translation
of ", " must be 2 characters.

If we change line 253 like the following, it may work but introduce another
string ", " for translation, and it looks weird.

253       strbuf_setlen(&extra, extra.len - strlen( _(", ") ));

It is because I translate the ", " to "," (chinese comma), the translated
chinese comma is 3 bytes long, striped two of them cause the output
looks weird.

It is also a bug hard to detect, If a careless translater lost the end space
in translation.


-- 
Jiang Xin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help