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 16-character width.

Set blame_date_width as the display width of _("4 years, 11 months
ago"), so that translators can make the choice.

Signed-off-by: Jiang Xin <worldhello....@gmail.com>
---
 builtin/blame.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 0a0a858..9350ea3 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2340,7 +2340,15 @@ parse_done:
                blame_date_width = sizeof("2006-10-19");
                break;
        case DATE_RELATIVE:
-               /* "normal" is used as the fallback for "relative" */
+               /* TRANSLATORS: what we care about is not the content itself,
+                  but the display width of this string.  We use the width of
+                  the string as the max width of the datetime in relative
+                  format.  For English and many other languages, "4 years,
+                  11 months ago" is the longest one among "89 seconds ago",
+                  "89 minites ago", "35 hours ago", "13 days ago", "10 weeks
+                  ago", "in the future" and many others. */
+               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");
-- 
2.0.0.rc0.3.g444188f.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to