Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit d52cb57

Browse files
committed
wt-status: make full label string to be subject to l10n
Earlier in 3651e45 (wt-status: take the alignment burden off translators, 2013-11-05), we assumed that it is OK to make the string before the colon in a label string we give as the section header of various kinds of changes (e.g. "new file:") translatable. This assumption apparently does not hold for some languages, e.g. ones that want to have spaces around the colon. Also introduce a static label_width to avoid having to run strlen(padding) over and over. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f95c9f commit d52cb57

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

wt-status.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,21 @@ static const char *wt_status_diff_status_string(int status)
272272
{
273273
switch (status) {
274274
case DIFF_STATUS_ADDED:
275-
return _("new file");
275+
return _("new file:");
276276
case DIFF_STATUS_COPIED:
277-
return _("copied");
277+
return _("copied:");
278278
case DIFF_STATUS_DELETED:
279-
return _("deleted");
279+
return _("deleted:");
280280
case DIFF_STATUS_MODIFIED:
281-
return _("modified");
281+
return _("modified:");
282282
case DIFF_STATUS_RENAMED:
283-
return _("renamed");
283+
return _("renamed:");
284284
case DIFF_STATUS_TYPE_CHANGED:
285-
return _("typechange");
285+
return _("typechange:");
286286
case DIFF_STATUS_UNKNOWN:
287-
return _("unknown");
287+
return _("unknown:");
288288
case DIFF_STATUS_UNMERGED:
289-
return _("unmerged");
289+
return _("unmerged:");
290290
default:
291291
return NULL;
292292
}
@@ -305,21 +305,21 @@ static void wt_status_print_change_data(struct wt_status *s,
305305
struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
306306
struct strbuf extra = STRBUF_INIT;
307307
static char *padding;
308+
static int label_width;
308309
const char *what;
309310
int len;
310311

311312
if (!padding) {
312-
int width = 0;
313313
/* If DIFF_STATUS_* uses outside this range, we're in trouble */
314314
for (status = 'A'; status <= 'Z'; status++) {
315315
what = wt_status_diff_status_string(status);
316316
len = what ? strlen(what) : 0;
317-
if (len > width)
318-
width = len;
317+
if (len > label_width)
318+
label_width = len;
319319
}
320-
width += 2; /* colon and a space */
321-
padding = xmallocz(width);
322-
memset(padding, ' ', width);
320+
label_width += strlen(" ");
321+
padding = xmallocz(label_width);
322+
memset(padding, ' ', label_width);
323323
}
324324

325325
one_name = two_name = it->string;
@@ -355,14 +355,13 @@ static void wt_status_print_change_data(struct wt_status *s,
355355
what = wt_status_diff_status_string(status);
356356
if (!what)
357357
die(_("bug: unhandled diff status %c"), status);
358-
/* 1 for colon, which is not part of "what" */
359-
len = strlen(padding) - (utf8_strwidth(what) + 1);
358+
len = label_width - utf8_strwidth(what);
360359
assert(len >= 0);
361360
if (status == DIFF_STATUS_COPIED || status == DIFF_STATUS_RENAMED)
362-
status_printf_more(s, c, "%s:%.*s%s -> %s",
361+
status_printf_more(s, c, "%s%.*s%s -> %s",
363362
what, len, padding, one, two);
364363
else
365-
status_printf_more(s, c, "%s:%.*s%s",
364+
status_printf_more(s, c, "%s%.*s%s",
366365
what, len, padding, one);
367366
if (extra.len) {
368367
status_printf_more(s, color(WT_STATUS_HEADER, s), "%s", extra.buf);

0 commit comments

Comments
 (0)