Skip to content

Commit

Permalink
blame: dynamic blame_date_width for different locales
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jiang Xin authored and Junio C Hamano committed Apr 23, 2014
1 parent bccce0f commit dd75553
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,14 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
blame_date_width = sizeof("2006-10-19");
break;
case DATE_RELATIVE:
/* "normal" is used as the fallback for "relative" */
/* TRANSLATORS: This string is used to tell us the maximum
display width for a relative timestamp in "git blame"
output. For C locale, "4 years, 11 months ago", which
takes 22 places, is the longest among various forms of
relative timestamps, but your language may need more or
fewer display columns. */
blame_date_width = utf8_strwidth(_("4 years, 11 months ago")) + 1; /* add the null */
break;
case DATE_LOCAL:
case DATE_NORMAL:
blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");
Expand Down

0 comments on commit dd75553

Please sign in to comment.