git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Raphael Hertzog" <hertzog@debian.org>,
	git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: git: problematic git status output with some translations (such as fr_FR)
Date: Wed, 12 Mar 2014 11:53:38 -0700	[thread overview]
Message-ID: <xmqqa9cvmeod.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20131219194319.GB20443@google.com> (Jonathan Nieder's message of "Thu, 19 Dec 2013 11:43:19 -0800")

Jonathan Nieder <jrnieder@gmail.com> writes:

> @@ -292,6 +291,48 @@ static const char *wt_status_diff_status_string(int status)
>  	}
>  }
>  
> +static int maxwidth(const char *(*label)(int), int minval, int maxval)
> +{
> +	const char *s;
> +	int result = 0, i;
> +
> +	for (i = minval; i <= maxval; i++) {
> +		const char *s = label(i);
> +		int len = s ? strlen(s) : 0;

Shouldn't this be a utf8_strwidth(), as the value is to count number
of display columns to be used by the leading label part?

> +		if (len > result)
> +			result = len;
> +	}
> +	return result;
> +}
> +
> +static void wt_status_print_unmerged_data(struct wt_status *s,
> +					  struct string_list_item *it)
> +{
> +	const char *c = color(WT_STATUS_UNMERGED, s);
> +	struct wt_status_change_data *d = it->util;
> +	struct strbuf onebuf = STRBUF_INIT;
> +	static char *padding;
> +	const char *one, *how;
> +	int len;
> +
> +	if (!padding) {
> +		int width = maxwidth(wt_status_unmerged_status_string, 1, 7);
> +		width += strlen(" ");
> +		padding = xmallocz(width);
> +		memset(padding, ' ', width);
> +	}
> +
> +	one = quote_path(it->string, s->prefix, &onebuf);
> +	status_printf(s, color(WT_STATUS_HEADER, s), "\t");
> +
> +	how = wt_status_unmerged_status_string(d->stagemask);
> +	if (!how)
> +		how = _("bug");

I'd rather see the callee do this _("bug") thing, not this
particular caller.

> +	len = strlen(padding) - utf8_strwidth(how);
> +	status_printf_more(s, c, "%s%.*s%s\n", how, len, padding, one);
> +	strbuf_release(&onebuf);
> +}

  parent reply	other threads:[~2014-03-12 18:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20131008085036.11434.25160.reportbug@x230-buxy.home.ouaza.com>
     [not found] ` <20131219104613.GA18379@x230-buxy.home.ouaza.com>
2013-12-19 19:43   ` git: problematic git status output with some translations (such as fr_FR) Jonathan Nieder
2013-12-19 20:46     ` Junio C Hamano
2013-12-19 20:50       ` Jonathan Nieder
2013-12-19 23:59         ` Duy Nguyen
2014-01-16 22:00           ` Raphael Hertzog
2014-02-08  9:51         ` Duy Nguyen
2014-03-12 18:53     ` Junio C Hamano [this message]
2014-03-12 19:22       ` [PATCH] wt-status: i18n of section labels Junio C Hamano
2014-03-12 20:05         ` Sandy Carter
2014-03-12 20:12           ` Junio C Hamano
2014-03-12 20:17             ` Sandy Carter
2014-03-13 18:01               ` Junio C Hamano

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=xmqqa9cvmeod.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hertzog@debian.org \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.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).