From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
Duy Nguyen <pclouds@gmail.com>,
Eric Sunshine <sunshine@sunshineco.com>
Cc: Brian Gesiak <modocache@gmail.com>,
Git List <git@vger.kernel.org>,
Jiang Xin <worldhello.net@gmail.com>
Subject: [PATCH v4 2/2] blame: dynamic blame_date_width for different locales
Date: Tue, 22 Apr 2014 22:39:10 +0800 [thread overview]
Message-ID: <2d4e186a742b03788a843b6afcd9fcd7575a5c37.1398177411.git.worldhello.net@gmail.com> (raw)
In-Reply-To: <cover.1398177411.git.worldhello.net@gmail.com>
In-Reply-To: <cover.1398177411.git.worldhello.net@gmail.com>
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>
---
builtin/blame.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 35e95db..128fc64 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2338,7 +2338,14 @@ parse_done:
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");
--
1.9.2.476.gff10cf3.dirty
next prev parent reply other threads:[~2014-04-22 14:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-18 8:44 [PATCH] blame: add correct paddings in time_buf for align Jiang Xin
2014-04-18 14:42 ` Duy Nguyen
2014-04-18 17:08 ` Junio C Hamano
2014-04-19 0:20 ` Duy Nguyen
2014-04-20 16:13 ` [PATCH v2 0/2] peroper align of datetime filed of git-blame Jiang Xin
2014-04-20 16:13 ` [PATCH v2 1/2] bugfix: fix broken time_buf paddings for git-blame Jiang Xin
2014-04-20 20:28 ` Eric Sunshine
2014-04-20 16:13 ` [PATCH v2 2/2] blame: use different blame_date_width for different locale Jiang Xin
2014-04-20 21:40 ` Junio C Hamano
2014-04-21 6:02 ` [PATCH v3 0/2] peroper align of datetime filed of git-blame Jiang Xin
2014-04-21 6:02 ` [PATCH v3 1/2] bugfix: fix broken time_buf paddings for git-blame Jiang Xin
2014-04-21 6:02 ` [PATCH v3 2/2] blame: use a helper to get suitable blame_date_width Jiang Xin
2014-04-21 17:20 ` Junio C Hamano
2014-04-21 19:19 ` Junio C Hamano
2014-04-22 12:25 ` Jiang Xin
2014-04-22 14:39 ` [PATCH v4 0/2] peroper align of datetime filed of git-blame Jiang Xin
2014-04-22 14:39 ` [PATCH v4 1/2] bugfix: fix broken time_buf paddings for git-blame Jiang Xin
2014-04-22 14:39 ` Jiang Xin [this message]
2014-04-22 10:01 ` [PATCH v2 2/2] blame: use different blame_date_width for different locale David Kastrup
2014-04-22 12:16 ` Jiang Xin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d4e186a742b03788a843b6afcd9fcd7575a5c37.1398177411.git.worldhello.net@gmail.com \
--to=worldhello.net@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=modocache@gmail.com \
--cc=pclouds@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).