Subject: Re: [RFC/PATCH] i18n of multi-line messages

From: Johannes Sixt <[email-masked]>
Date: Thu, 22 Dec 2011 07:54:46 +0100

Am 12/22/2011 0:55, schrieb Junio C Hamano:
>  void advise(const char *advice, ...)
>  {
> +	struct strbuf buf = STRBUF_INIT;
>  	va_list params;
> +	const char *cp, *np;
>  
>  	va_start(params, advice);
> -	vreportf("hint: ", advice, params);
> +	strbuf_addf(&buf, advice, params);
>  	va_end(params);
> +
> +	for (cp = buf.buf; *cp; cp = np) {
> +		np = strchrnul(cp, '\n');
> +		fprintf(stderr, "%s%.*s\n", _("hint: "), (int)(np - cp), cp);
> +		if (*np)
> +			np++;
> +	}
> +	strbuf_release(&buf);
>  }

IMHO, this logic should be moved into vreportf(), and we get proper
prefixing of multi-line warning(), error(), and die() messages for free.

> +		advise(_("Fix them up in the work tree,\n"
> +			 "and then use 'git add/rm <file>' as\n"
> +			 "appropriate to mark resolution and make a commit,\n"
> +			 "or use 'git commit -a'."));

<rant>
Can people please pay attention how they break multi-line messages? In
this particular case, (1) even in a 80-columns terminal the lines are
spectacularly short, and (2) a break in the middle of a word group can
easily be avoided such that the result does not look ugly:

hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.

And, no, "It would break the 80-column limit of source code" does not
count for user-visible messages.
</rant>

-- Hannes