git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Make a colon translatable
@ 2022-04-11  7:02 Julien Palard
  2022-04-11 19:29 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Julien Palard @ 2022-04-11  7:02 UTC (permalink / raw)
  To: git@vger.kernel.org; +Cc: Sébastien Helleu, Jean-Noël Avila

In french we use a no-break space before colon, so with formatting
like:

    printf("... %s: ...", _("some string"))

We can't cleanly add our no-break space, so I think:

    printf("... %s ...", _("some string:"))

is better for translators.

Signed-off-by: Julien Palard <julien@palard.fr>
---
 wt-status.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index d33f9272b7..ef0c276c3d 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -248,7 +248,7 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
 					     const char *how)
 {
 	const char *c = color(WT_STATUS_HEADER, s);
-	status_printf_ln(s, c, "%s:", what);
+	status_printf_ln(s, c, "%s", what);
 	if (!s->hints)
 		return;
 	status_printf_ln(s, c, _("  (use \"git %s <file>...\" to include in what will be committed)"), how);
@@ -1863,9 +1863,9 @@ static void wt_longstatus_print(struct wt_status *s)
 		wt_longstatus_print_submodule_summary(s, 1);  /* unstaged */
 	}
 	if (s->show_untracked_files) {
-		wt_longstatus_print_other(s, &s->untracked, _("Untracked files"), "add");
+		wt_longstatus_print_other(s, &s->untracked, _("Untracked files:"), "add");
 		if (s->show_ignored_mode)
-			wt_longstatus_print_other(s, &s->ignored, _("Ignored files"), "add -f");
+			wt_longstatus_print_other(s, &s->ignored, _("Ignored files:"), "add -f");
 		if (advice_enabled(ADVICE_STATUS_U_OPTION) && 2000 < s->untracked_in_ms) {
 			status_printf_ln(s, GIT_COLOR_NORMAL, "%s", "");
 			status_printf_ln(s, GIT_COLOR_NORMAL,
--
2.35.1

-- 
Julien Palard
https://mdk.fr

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-11  7:02 [PATCH] Make a colon translatable Julien Palard
@ 2022-04-11 19:29 ` Junio C Hamano
  2022-04-12  7:30   ` Julien Palard
  2022-04-12  8:03   ` Ævar Arnfjörð Bjarmason
  0 siblings, 2 replies; 8+ messages in thread
From: Junio C Hamano @ 2022-04-11 19:29 UTC (permalink / raw)
  To: Julien Palard
  Cc: git@vger.kernel.org, Sébastien Helleu, Jean-Noël Avila

Julien Palard <julien@palard.fr> writes:

> In french we use a no-break space before colon, so with formatting
> like:
>
>     printf("... %s: ...", _("some string"))
>
> We can't cleanly add our no-break space, so I think:
>
>     printf("... %s ...", _("some string:"))

Sorry, but I do not quite buy this.  The above is a representative
example of what we call "sentence lego", which is what we absolutely
want to avoid, isn't it?

We'd rather want to see

	printf_like_function(_("Use 'git %s' ...", "string"));

when "string" is something that should not be translated to begin
with (e.g. "add" to form "git add"), and different languages can use
different conventions for quoting the command name (a translation
may want to use something other than single-quotes, for example).

And in a less optimal case,

	printf_like_function(_("%s: ...", _("string")));

would be needed, when "string" is something that is to be translated
(e.g. a phrase used as a label, like "Untracked files" in the code
this patch touches).  I think the case you have is the latter one.

> diff --git a/wt-status.c b/wt-status.c
> index d33f9272b7..ef0c276c3d 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -248,7 +248,7 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
>  					     const char *how)
>  {
>  	const char *c = color(WT_STATUS_HEADER, s);
> -	status_printf_ln(s, c, "%s:", what);
> +	status_printf_ln(s, c, "%s", what);

I.e. this one is better handled by

	status_printf_ln(s, c, _("%s:"), what);

as _(...) in C-locale is original-language centric, where we want
the label to be <phrase> immediately followed by a colon.  And that
allows French translation to have nbsp before the colon.

>  	if (s->show_untracked_files) {
> -		wt_longstatus_print_other(s, &s->untracked, _("Untracked files"), "add");
> +		wt_longstatus_print_other(s, &s->untracked, _("Untracked files:"), "add");

Then this <phrase>, to be used in the label above, can be without colon.

>  		if (s->show_ignored_mode)
> -			wt_longstatus_print_other(s, &s->ignored, _("Ignored files"), "add -f");
> +			wt_longstatus_print_other(s, &s->ignored, _("Ignored files:"), "add -f");

Ditto.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-11 19:29 ` Junio C Hamano
@ 2022-04-12  7:30   ` Julien Palard
  2022-04-12 16:26     ` Junio C Hamano
  2022-04-12  8:03   ` Ævar Arnfjörð Bjarmason
  1 sibling, 1 reply; 8+ messages in thread
From: Julien Palard @ 2022-04-12  7:30 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git@vger.kernel.org, Sébastien Helleu, Jean-Noël Avila

Hi, thanks for you feedback!

> Sorry, but I do not quite buy this. The above is a representative
> example of what we call "sentence lego", which is what we absolutely
> want to avoid, isn't it?

I never heard of "sentence lego" but I can easily imagine it's building sentences by mixing multiple levels of gettext and printf-like formatting, typically freezing the order of sentence components, rendering them untranslatable in some languages, like printf(_("if %s then %s"), _(if_part), _(then_part))? I I'm wrong tell me because I may have misundertood your whole point.

> We'd rather want to see
>
> printf_like_function(("Use 'git %s' ...", "string"));
>
> when "string" is something that should not be translated

Make sense.

> I.e. this one is better handled by
>
> status_printf_ln(s, c, _("%s:"), what);

I understand your comment while seeing my badly choosen example with `_("some string:")`, but in the patch isn't your proposition more sentence-lego-ish than mine? If I understand correctly you're proposing to replace:

    printf("%s", _("Untracked files:"))

with:

    printf(_("%s:"), _("Untracked files"))

This hides information to the translator (the presence of a following colon while translating 'Untracked files'). It would be OK if we were 100% sure no translations can be impacted by this. I only speak french and english, so I don't know. Maybe I should rename `what` to `heading`? I may clarify a bit, `what` make me feel it can be reused, but it's only used once alone on its line.

Bests,
-- 
Julien Palard
https://mdk.fr


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-11 19:29 ` Junio C Hamano
  2022-04-12  7:30   ` Julien Palard
@ 2022-04-12  8:03   ` Ævar Arnfjörð Bjarmason
  2022-04-12 16:32     ` Junio C Hamano
  1 sibling, 1 reply; 8+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-04-12  8:03 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Julien Palard, git@vger.kernel.org, Sébastien Helleu,
	Jean-Noël Avila


On Mon, Apr 11 2022, Junio C Hamano wrote:

> Julien Palard <julien@palard.fr> writes:
>
>> In french we use a no-break space before colon, so with formatting
>> like:
>>
>>     printf("... %s: ...", _("some string"))
>>
>> We can't cleanly add our no-break space, so I think:
>>
>>     printf("... %s ...", _("some string:"))
>
> Sorry, but I do not quite buy this.  The above is a representative
> example of what we call "sentence lego", which is what we absolutely
> want to avoid, isn't it?
>
> We'd rather want to see
>
> 	printf_like_function(_("Use 'git %s' ...", "string"));
>
> when "string" is something that should not be translated to begin
> with (e.g. "add" to form "git add"), and different languages can use
> different conventions for quoting the command name (a translation
> may want to use something other than single-quotes, for example).
>
> And in a less optimal case,
>
> 	printf_like_function(_("%s: ...", _("string")));
>
> would be needed, when "string" is something that is to be translated
> (e.g. a phrase used as a label, like "Untracked files" in the code
> this patch touches).  I think the case you have is the latter one.

You're right, but wt-status.c is sentence lego galore, and that's been a
TODO since the i18n effort was started.

It's particularly hard to peel it apart, and doing so would require
e.g. having translators translate a string with embedded color formats,
or even git-for-each-ref embedded %(if...) formats.

But in lieu of that I don't see a reson for not taking this much more
narrow change, since it solves a practical issue for a major language...

>> diff --git a/wt-status.c b/wt-status.c
>> index d33f9272b7..ef0c276c3d 100644
>> --- a/wt-status.c
>> +++ b/wt-status.c
>> @@ -248,7 +248,7 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
>>  					     const char *how)
>>  {
>>  	const char *c = color(WT_STATUS_HEADER, s);
>> -	status_printf_ln(s, c, "%s:", what);
>> +	status_printf_ln(s, c, "%s", what);
>
> I.e. this one is better handled by
>
> 	status_printf_ln(s, c, _("%s:"), what);
>
> as _(...) in C-locale is original-language centric, where we want
> the label to be <phrase> immediately followed by a colon.  And that
> allows French translation to have nbsp before the colon.

In this case I think the change as suggested is better, translators get
zero context from "%s:", whereas "Untracked files:" being status output
is immediately obvious.

>>  	if (s->show_untracked_files) {
>> -		wt_longstatus_print_other(s, &s->untracked, _("Untracked files"), "add");
>> +		wt_longstatus_print_other(s, &s->untracked, _("Untracked files:"), "add");
>
> Then this <phrase>, to be used in the label above, can be without colon.
>
>>  		if (s->show_ignored_mode)
>> -			wt_longstatus_print_other(s, &s->ignored, _("Ignored files"), "add -f");
>> +			wt_longstatus_print_other(s, &s->ignored, _("Ignored files:"), "add -f");

It's a good rule of thumb to give translators the "whole thing", in this
case that's a heading, so despite other issues with lego'd "status"
output this particular string is following best-practices after this
change by Julien.

His commit message also doesn't mention it, but for existing "headings"
we already do this, e.g.:

    status_printf_ln(s, c, _("Changes to be committed:"));
    status_printf_ln(s, c, _("Changes not staged for commit:"));

etc., grep for status_printf_ln.*" in that file, so this is making
things consistent with that other code.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-12  7:30   ` Julien Palard
@ 2022-04-12 16:26     ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2022-04-12 16:26 UTC (permalink / raw)
  To: Julien Palard
  Cc: git@vger.kernel.org, Sébastien Helleu, Jean-Noël Avila

Julien Palard <julien@palard.fr> writes:

> I understand your comment while seeing my badly choosen example
> with `_("some string:")`, but in the patch isn't your proposition
> more sentence-lego-ish than mine? If I understand correctly you're
> proposing to replace:
>
>     printf("%s", _("Untracked files:"))
>
> with:
>
>     printf(_("%s:"), _("Untracked files"))

Hmph, I am talking about

diff --git i/wt-status.c w/wt-status.c
index d33f9272b7..f475194ff8 100644
--- i/wt-status.c
+++ w/wt-status.c
@@ -249,5 +249,5 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
 {
 	const char *c = color(WT_STATUS_HEADER, s);
-	status_printf_ln(s, c, "%s:", what);
+	status_printf_ln(s, c, _("%s:"), what);
 	if (!s->hints)
 		return;

where the callers already supply _("Untracked files") and _("Ignored files")
without trailing colon in "what" when calling wt_longstatus_print_other(),
which is a direct caller that passes "what" to this function.

So, no, I am replacing

	printf("%s:", _("Untracked files"))

with

	printf(_("%s:"), _("Untracked files"))

and no other changes are required.  When translating "%s:", French
translation can insert nbsp before the colon to make it "%s :",
right to left languages may want to put their equivalent to colon
that comes after a heading on the left side of the "%s", etc.

> This hides information to the translator (the presence of a
> following colon while translating 'Untracked files').

With "Untracked files" and "Ignored files", we indicate certain
concepts and interpolate it in _("%s:"), i.e. a version localized to
adjust to the presentation convention of "label followed by a
separating colon".  Unless your language requires to translate
"Untracked files" differently when it is used as a "label" to be
followed by a separating colon and when it appears elsewhere in a
sentence, I am not sure how it helps to mark "Untracked files" as
appearing as a header label.

Besides, in the existing code, the form that is equivalent to

	printf("%s:", _("Untracked files"))

is being used, and where that "Untracked files" appear is two level
function calls away from the actual "%s:" (i.e. "label and
separator").  Aren't translators translating this string without
extra context?

> It would be
> OK if we were 100% sure no translations can be impacted by this. I
> only speak french and english, so I don't know. Maybe I should
> rename `what` to `heading`? I may clarify a bit, `what` make me
> feel it can be reused, but it's only used once alone on its line.

The way the function wt_longstatus_print_other() uses "what" and
"how" looks quite clear.  What kind of paths are being reported (are
they ignored files?  untracked files?  something else?) and how the
user can rectify the situation if they want these paths included in
the tracked set of paths.  I am afraid renaming to "heading" makes
it even less clear than leaving it to "what".  A word that indicates
that it refers to "category of paths" more clearly may make a good
replacement, but perhaps I am not understanding where exactly your
"this hides the information" comes from and makes you worry about
it.  Besides, would translators work off of .po and .pot files, not
the C-source?  Do they even have ready access to the variable names
to help them infer how the strings are used to begin with?

If translators truly benefit from knowing that the string "Untracked
files" is used as a heading, we could use /* TRANSLATORS: insn */
comment to help them.  Since I seem not to get where your concern
comes from, I cannot tell if it would help.

More info needed, I guess?

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-12  8:03   ` Ævar Arnfjörð Bjarmason
@ 2022-04-12 16:32     ` Junio C Hamano
  2022-04-13 13:11       ` Jean-Noël Avila
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2022-04-12 16:32 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Julien Palard, git@vger.kernel.org, Sébastien Helleu,
	Jean-Noël Avila

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>>> --- a/wt-status.c
>>> +++ b/wt-status.c
>>> @@ -248,7 +248,7 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
>>>  					     const char *how)
>>>  {
>>>  	const char *c = color(WT_STATUS_HEADER, s);
>>> -	status_printf_ln(s, c, "%s:", what);
>>> +	status_printf_ln(s, c, "%s", what);
>>
>> I.e. this one is better handled by
>>
>> 	status_printf_ln(s, c, _("%s:"), what);
>>
>> as _(...) in C-locale is original-language centric, where we want
>> the label to be <phrase> immediately followed by a colon.  And that
>> allows French translation to have nbsp before the colon.
>
> In this case I think the change as suggested is better, translators get
> zero context from "%s:", whereas "Untracked files:" being status output
> is immediately obvious.

It is unclear if you read the original (and discussion so far).

I understand that Julien wants to turn "%s:" to have nonbreaking
whitespace before the colon.  It does not matter what label we are
using (it can be "Ignored files").  I took it that the patch is
addressing "git status" output but the general thrust is in Julien's
translation, all "label-string followed by colon" should become "the
string followed by nonbreaking whitespace followed by colon".

Moving the colon to the label string is backwards, isn't it?  If the
presentation form accepted in the C-locale, i.e. "%s:", needs to be
localized in Julien's translation to "%s :", shouldn't the "%s:"
that defines the presentation be what is marked for translation?

> His commit message also doesn't mention it, but for existing "headings"
> we already do this, e.g.:
>
>     status_printf_ln(s, c, _("Changes to be committed:"));
>     status_printf_ln(s, c, _("Changes not staged for commit:"));

That's another arugment to translate _("%s:") once for the language,
I would think.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-12 16:32     ` Junio C Hamano
@ 2022-04-13 13:11       ` Jean-Noël Avila
  2022-04-13 16:48         ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Jean-Noël Avila @ 2022-04-13 13:11 UTC (permalink / raw)
  To: Junio C Hamano, Ævar Arnfjörð Bjarmason
  Cc: Julien Palard, git@vger.kernel.org, Sébastien Helleu

Le 12/04/2022 à 18:32, Junio C Hamano a écrit :
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> 
>>>> --- a/wt-status.c
>>>> +++ b/wt-status.c
>>>> @@ -248,7 +248,7 @@ static void wt_longstatus_print_other_header(struct wt_status *s,
>>>>   					     const char *how)
>>>>   {
>>>>   	const char *c = color(WT_STATUS_HEADER, s);
>>>> -	status_printf_ln(s, c, "%s:", what);
>>>> +	status_printf_ln(s, c, "%s", what);
>>>
>>> I.e. this one is better handled by
>>>
>>> 	status_printf_ln(s, c, _("%s:"), what);
>>>
>>> as _(...) in C-locale is original-language centric, where we want
>>> the label to be <phrase> immediately followed by a colon.  And that
>>> allows French translation to have nbsp before the colon.
>>
>> In this case I think the change as suggested is better, translators get
>> zero context from "%s:", whereas "Untracked files:" being status output
>> is immediately obvious.
> 
> It is unclear if you read the original (and discussion so far).
> 
> I understand that Julien wants to turn "%s:" to have nonbreaking
> whitespace before the colon.  It does not matter what label we are
> using (it can be "Ignored files").  I took it that the patch is
> addressing "git status" output but the general thrust is in Julien's
> translation, all "label-string followed by colon" should become "the
> string followed by nonbreaking whitespace followed by colon".
> 
> Moving the colon to the label string is backwards, isn't it?  If the
> presentation form accepted in the C-locale, i.e. "%s:", needs to be
> localized in Julien's translation to "%s :", shouldn't the "%s:"
> that defines the presentation be what is marked for translation?
> 
>> His commit message also doesn't mention it, but for existing "headings"
>> we already do this, e.g.:
>>
>>      status_printf_ln(s, c, _("Changes to be committed:"));
>>      status_printf_ln(s, c, _("Changes not staged for commit:"));
> 
> That's another arugment to translate _("%s:") once for the language,
> I would think.

Just to chime in, I would tend to approve Julien's proposal, but with a 
reworded commit message, which should convey that the segment to 
translate is not a full sentence.


The main argument is that for translators to correctly work, the strings 
to translate must hold complete sentences, comprising the end colon. I 
guess that in the present case, we are quite lucky that these strings 
appear so often that translators know how to handle them.

Why use a /* TRANSLATORS:*/ stance when simply providing the full 
sentence would not require any additional hint and uniformize it to the 
general way of presenting strings to translators. This is an indication 
that the string is not a complete semantic entity, although we can 
provide it (e.g. just like for the other ones, lines 284-305).

Also making a string as generic as "%s:" translatable can lead to 
translation errors because this has the structure of sentence lego where 
we can be sure that the %s is another translated string.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Make a colon translatable
  2022-04-13 13:11       ` Jean-Noël Avila
@ 2022-04-13 16:48         ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2022-04-13 16:48 UTC (permalink / raw)
  To: Jean-Noël Avila
  Cc: Ævar Arnfjörð Bjarmason, Julien Palard,
	git@vger.kernel.org, Sébastien Helleu

Jean-Noël Avila <jn.avila@free.fr> writes:

> Just to chime in, I would tend to approve Julien's proposal, but with
> a reworded commit message, which should convey that the segment to 
> translate is not a full sentence.

Thanks.  I think that is probably a sensible thing to do.  The use
of "%s:" (or "%s") is necessitated by the use of status_printf_ln()
in

    status_printf_ln(s, c, "%s", what);

and if we had status_puts() instead, we wouldn't be having this
discussion, as the line would have been

    status_puts(s, c, what);

and it is obvious that "what" (aka "label heading") wants to have
colon after it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-13 16:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11  7:02 [PATCH] Make a colon translatable Julien Palard
2022-04-11 19:29 ` Junio C Hamano
2022-04-12  7:30   ` Julien Palard
2022-04-12 16:26     ` Junio C Hamano
2022-04-12  8:03   ` Ævar Arnfjörð Bjarmason
2022-04-12 16:32     ` Junio C Hamano
2022-04-13 13:11       ` Jean-Noël Avila
2022-04-13 16:48         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).