git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] advice: omit trailing whitespace

From
Rubén Justo <rjusto@gmail.com>
Date
Apr 1, 2024, 20:50 UTC
Message-ID
<b71785c5-b93e-41aa-86c1-d05703365240@gmail.com>
In-Reply-To
<xmqqo7auf3h5.fsf@gitster.g>
On Sun, Mar 31, 2024 at 03:20:22PM -0700, Junio C Hamano wrote:
Show 51 quoted lines
> Rubén Justo <rjusto@gmail.com> writes:
> 
> >> > > and move the "hint" literal to the args, to ease the translation work:
> >> > > -               fprintf(stderr, _("%shint:%s%.*s%s\n"),
> >> > > +               fprintf(stderr, "%s%s:%s%.*s%s\n",
> >> > >                         advise_get_color(ADVICE_COLOR_HINT),
> >> > > +                       _("hint"),
> >> > >                         (np == cp) ? "" : " ",
> >> > >                         (int)(np - cp), cp,
> >> > >                         advise_get_color(ADVICE_COLOR_RESET));
> >> > 
> >> > It is not guaranteed that any and all languages want to use a colon
> >> > immediately after translation of "hint"; the current message string
> >> > with or without my patch allows translators adjust that part to the
> >> > target language, but your version will force them to always use only
> >> > a colon there.  Is that an improvement?  I somehow do not think so.
> >> 
> >> I was just thinking if leaving the format open to the translation is a
> >> sane option.  Maybe we can move the colon to the literal in the args,
> >> too.
> >
> > Just for the record, zh_CN (Chinese) and zh_TW (Traditional Chinese)
> > do not use ':' on its translation, but ':'
> >
> > So, if we go the way I proposed we'll need to move the ':' too.  I
> > still think it's an improvement.  But, optional to this series.
> 
> It is making it even worse.
> 
> Giving larger unit to work with to translators is usually a better
> for i18n than chopping a single logical message into multiple pieces
> and paste them together in the code, as your untranslated
> format-string (e.g., "%s%s:%s%.*s%s\n" we see above) will force the
> word order in the final output.
> 
> I think the patch at the beginning of the thread is more than
> serviceable, but if we wanted to improve on it, we should go in the
> opposite direction, e.g.
> 
> 	if (np == cp)
> 		fprintf(stderr, _("%shint:%s\n"),
> 			advise_get_color(ADVICE_COLOR_HINT),
> 			advise_get_color(ADVICE_COLOR_RESET));
> 	else
> 		fprintf(stderr, _("%shint: %.*s%s\n"),
> 			advise_get_color(ADVICE_COLOR_HINT),
> 			(int)(np - cp), cp,
> 			advise_get_color(ADVICE_COLOR_RESET));
> 
> to give translators flexibility to choose what kind of space to use
> (including "none") after "hint:".
diff --git a/advice.c b/advice.c
index a18bfe776f..a625316725 100644
--- a/advice.c
+++ b/advice.c
@@ -104,9 +104,9 @@ static void vadvise(const char *advice, int display_instructions,

        for (cp = buf.buf; *cp; cp = np) {
                np = strchrnul(cp, '\n');
-               fprintf(stderr, _("%shint:%s%.*s%s\n"),
+               fprintf(stderr, "%s%s%s%.*s%s\n",
                        advise_get_color(ADVICE_COLOR_HINT),
-                       (np == cp) ? "" : " ",
+                       (np == cp) ? _("hint:") : _("hint: "),
                        (int)(np - cp), cp,
                        advise_get_color(ADVICE_COLOR_RESET));
                if (*np)

;)

> 
> I am not going to do that, though, until/unless somebody complains
> and says "there is no inter-word spaces and it is more customary not
> to have a space after the translation of 'hint:' in my language".
Previous: Junio C HamanoNext: Dragan Simic
Message 8 of 9 in “advice: omit trailing whitespace”
  1. advice: omit trailing whitespaceJunio C Hamano, Mar 29, 2024
  2. Rubén JustoMar 29, 2024
  3. Rubén JustoMar 31, 2024
  4. Junio C HamanoMar 31, 2024
  5. Rubén JustoMar 31, 2024
  6. Rubén JustoMar 31, 2024
  7. Junio C HamanoMar 31, 2024
  8. Rubén JustoApr 1, 2024
  9. Dragan SimicMar 29, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.