]> git.ipfire.org Git - thirdparty/git.git/commitdiff
wt-status: make full label string to be subject to l10n
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2014 20:51:22 +0000 (13:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2014 21:07:30 +0000 (14:07 -0700)
Earlier in 3651e45c (wt-status: take the alignment burden off
translators, 2013-11-05), we assumed that it is OK to make the
string before the colon in a label string we give as the section
header of various kinds of changes (e.g. "new file:") translatable.

This assumption apparently does not hold for some languages,
e.g. ones that want to have spaces around the colon.

Also introduce a static label_width to avoid having to run
strlen(padding) over and over.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c

index 4e5581005936a1e7832e3ab224cfe142ac777a63..9cf70287d9aae08e74d5afb9d54a6ba9aad62121 100644 (file)
@@ -272,21 +272,21 @@ static const char *wt_status_diff_status_string(int status)
 {
        switch (status) {
        case DIFF_STATUS_ADDED:
-               return _("new file");
+               return _("new file:");
        case DIFF_STATUS_COPIED:
-               return _("copied");
+               return _("copied:");
        case DIFF_STATUS_DELETED:
-               return _("deleted");
+               return _("deleted:");
        case DIFF_STATUS_MODIFIED:
-               return _("modified");
+               return _("modified:");
        case DIFF_STATUS_RENAMED:
-               return _("renamed");
+               return _("renamed:");
        case DIFF_STATUS_TYPE_CHANGED:
-               return _("typechange");
+               return _("typechange:");
        case DIFF_STATUS_UNKNOWN:
-               return _("unknown");
+               return _("unknown:");
        case DIFF_STATUS_UNMERGED:
-               return _("unmerged");
+               return _("unmerged:");
        default:
                return NULL;
        }
@@ -305,21 +305,21 @@ static void wt_status_print_change_data(struct wt_status *s,
        struct strbuf onebuf = STRBUF_INIT, twobuf = STRBUF_INIT;
        struct strbuf extra = STRBUF_INIT;
        static char *padding;
+       static int label_width;
        const char *what;
        int len;
 
        if (!padding) {
-               int width = 0;
                /* If DIFF_STATUS_* uses outside this range, we're in trouble */
                for (status = 'A'; status <= 'Z'; status++) {
                        what = wt_status_diff_status_string(status);
                        len = what ? strlen(what) : 0;
-                       if (len > width)
-                               width = len;
+                       if (len > label_width)
+                               label_width = len;
                }
-               width += 2;     /* colon and a space */
-               padding = xmallocz(width);
-               memset(padding, ' ', width);
+               label_width += strlen(" ");
+               padding = xmallocz(label_width);
+               memset(padding, ' ', label_width);
        }
 
        one_name = two_name = it->string;
@@ -355,14 +355,13 @@ static void wt_status_print_change_data(struct wt_status *s,
        what = wt_status_diff_status_string(status);
        if (!what)
                die(_("bug: unhandled diff status %c"), status);
-       /* 1 for colon, which is not part of "what" */
-       len = strlen(padding) - (utf8_strwidth(what) + 1);
+       len = label_width - utf8_strwidth(what);
        assert(len >= 0);
        if (status == DIFF_STATUS_COPIED || status == DIFF_STATUS_RENAMED)
-               status_printf_more(s, c, "%s:%.*s%s -> %s",
+               status_printf_more(s, c, "%s%.*s%s -> %s",
                                   what, len, padding, one, two);
        else
-               status_printf_more(s, c, "%s:%.*s%s",
+               status_printf_more(s, c, "%s%.*s%s",
                                   what, len, padding, one);
        if (extra.len) {
                status_printf_more(s, color(WT_STATUS_HEADER, s), "%s", extra.buf);