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 <gitster@pobox.com> Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jiang Xin committed
Apr 22, 2014 at 22:39 UTC
dd75553b357d4483d2b58a9e1ac86352f3d2e103
1 file changed
+8
-1
builtin/blame.c
+8
-1
@@ -2338,7 +2338,14 @@ parse_done:
2338
blame_date_width = sizeof("2006-10-19");
2339
break;
2340
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;
2349
case DATE_LOCAL:
2350
case DATE_NORMAL:
2351
blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");