Skip to content

Commit dd75553

Browse files
jiangxingitster
authored andcommitted
blame: dynamic blame_date_width for different locales
When show date in relative date format for git-blame, the max display width of datetime is set as the length of the string "Thu Oct 19 16:00:04 2006 -0700" (30 characters long). But actually the max width for C locale is only 22 (the length of string "x years, xx months ago"). And for other locale, it maybe smaller. E.g. For Chinese locale, only needs a half (16-character width). Set blame_date_width as the display width of _("4 years, 11 months ago"), so that translators can make the choice. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Jiang Xin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bccce0f commit dd75553

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

builtin/blame.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,14 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
23382338
blame_date_width = sizeof("2006-10-19");
23392339
break;
23402340
case DATE_RELATIVE:
2341-
/* "normal" is used as the fallback for "relative" */
2341+
/* TRANSLATORS: This string is used to tell us the maximum
2342+
display width for a relative timestamp in "git blame"
2343+
output. For C locale, "4 years, 11 months ago", which
2344+
takes 22 places, is the longest among various forms of
2345+
relative timestamps, but your language may need more or
2346+
fewer display columns. */
2347+
blame_date_width = utf8_strwidth(_("4 years, 11 months ago")) + 1; /* add the null */
2348+
break;
23422349
case DATE_LOCAL:
23432350
case DATE_NORMAL:
23442351
blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");

0 commit comments

Comments
 (0)