* [Outreachy PATCH] checkout: use Q_() for the "... and %d more" message
@ 2026-10-21 2:21 Tanga Joris
2026-10-21 18:04 ` Junio C Hamano
2026-10-22 0:48 ` [Outreachy PATCH v2] checkout: use Q_() for messages with counts Tanga Joris
0 siblings, 2 replies; 5+ messages in thread
From: Tanga Joris @ 2026-10-21 2:21 UTC (permalink / raw)
To: git; +Cc: christian.couder, siddharthasthana31, Tanga Joris
When leaving orphaned commits behind, "git checkout" ends the list
with " ... and %d more." using a plain _(), so translators are unable
to give the correct plural form of the count. Use Q_() so gettext can
pick it. English string output stays the same.
Signed-off-by: Tanga Joris <tangajoris@gmail.com>
---
The count here is always 2 or more, because when only one commit is
left over, the suggest_reattach() function lists it instead of printing
this message. I still used Q_() because some languages, like Polish,
use different words for 2-4 and for 5 or more.
builtin/checkout.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2d575a4f57..49239f029f 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1085,7 +1085,9 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
if (more == 1)
describe_one_orphan(&sb, last);
else
- strbuf_addf(&sb, _(" ... and %d more.\n"), more);
+ strbuf_addf(&sb, Q_(" ... and %d more.\n",
+ " ... and %d more.\n",
+ more), more);
}
fprintf(stderr,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Outreachy PATCH] checkout: use Q_() for the "... and %d more" message
2026-10-21 2:21 [Outreachy PATCH] checkout: use Q_() for the "... and %d more" message Tanga Joris
@ 2026-10-21 18:04 ` Junio C Hamano
2026-10-21 21:04 ` Tanga Joris
2026-10-22 0:48 ` [Outreachy PATCH v2] checkout: use Q_() for messages with counts Tanga Joris
1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2026-10-21 18:04 UTC (permalink / raw)
To: Tanga Joris; +Cc: git, christian.couder, siddharthasthana31
Tanga Joris <tangajoris@gmail.com> writes:
> When leaving orphaned commits behind, "git checkout" ends the list
> with " ... and %d more." using a plain _(), so translators are unable
> to give the correct plural form of the count. Use Q_() so gettext can
> pick it. English string output stays the same.
Is the last sentence worth saying? I am having a hard time
imagining who it helps.
Translators of a language that phrases "2 more" and "3 more" the
same way now have to translate this placeholder twice. At that
cost, however, we help translators of languages that need to phrase
"2 more", "3 more", and "5 more" differently.
That is something we may want to say instead.
> Signed-off-by: Tanga Joris <tangajoris@gmail.com>
> ---
> The count here is always 2 or more, because when only one commit is
> left over, the suggest_reattach() function lists it instead of printing
> this message. I still used Q_() because some languages, like Polish,
> use different words for 2-4 and for 5 or more.
>
> builtin/checkout.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 2d575a4f57..49239f029f 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1085,7 +1085,9 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
> if (more == 1)
> describe_one_orphan(&sb, last);
> else
> - strbuf_addf(&sb, _(" ... and %d more.\n"), more);
> + strbuf_addf(&sb, Q_(" ... and %d more.\n",
> + " ... and %d more.\n",
> + more), more);
> }
>
> fprintf(stderr,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Outreachy PATCH] checkout: use Q_() for the "... and %d more" message
2026-10-21 18:04 ` Junio C Hamano
@ 2026-10-21 21:04 ` Tanga Joris
0 siblings, 0 replies; 5+ messages in thread
From: Tanga Joris @ 2026-10-21 21:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, christian.couder, siddharthasthana31
On Wed, 21 Oct 2026 at 21:04, Junio C Hamano <gitster@pobox.com> wrote:
> Is the last sentence worth saying? I am having a hard time
> imagining who it helps.
>
> Translators of a language that phrases "2 more" and "3 more" the
> same way now have to translate this placeholder twice. At that
> cost, however, we help translators of languages that need to phrase
> "2 more", "3 more", and "5 more" differently.
>
> That is something we may want to say instead.
This makes sense, and thanks for the review and suggestion. I'll use your
explanation of the trade-off in place of that sentence in v2. v2 will
also convert
"only one reference expected, %d given." in the same file, following
Tuomas's suggestion in another thread [1].
[1] https://lore.kernel.org/git/20261021110616.Wxkhc%25taahol@utu.fi/
Thanks,
Tanga
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Outreachy PATCH v2] checkout: use Q_() for messages with counts
2026-10-21 2:21 [Outreachy PATCH] checkout: use Q_() for the "... and %d more" message Tanga Joris
2026-10-21 18:04 ` Junio C Hamano
@ 2026-10-22 0:48 ` Tanga Joris
2026-10-23 17:55 ` Junio C Hamano
1 sibling, 1 reply; 5+ messages in thread
From: Tanga Joris @ 2026-10-22 0:48 UTC (permalink / raw)
To: git
Cc: christian.couder, siddharthasthana31, kaartic.sivaraam,
usmanakinyemi202, taahol, ibnmuhyideen95, Tanga Joris,
Junio C Hamano
Two messages in builtin/checkout.c show a count but are
marked with a plain _(), so translators can only give a
single form for them:
- " ... and %d more." at the end of the list of orphaned
commits left behind when leaving a detached HEAD, and
- "only one reference expected, %d given." when more than
one reference is given before "--".
Use Q_() for both. Translators of a language that phrases
"2 more" and "3 more" the same way now have to translate
these messages twice. At that cost, however, we help
translators of languages that need to phrase "2 more",
"3 more", and "5 more" differently.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Tanga Joris <tangajoris@gmail.com>
---
Changes since v1:
- Replaced the last sentence of the log message with
a better explanation of the trade-off.
- Also converted "only one reference expected, %d given.",
as discussed by Tuomas in Mudi's thread.
Interdiff against v1:
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 49239f029f..91b7c52396 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1491,7 +1491,9 @@ static int parse_branchname_arg(int argc, const char **argv,
else if (dash_dash_pos == 1)
has_dash_dash = 1; /* case (3) or (1) */
else if (dash_dash_pos >= 2)
- die(_("only one reference expected, %d given."), dash_dash_pos);
+ die(Q_("only one reference expected, %d given.",
+ "only one reference expected, %d given.",
+ dash_dash_pos), dash_dash_pos);
opts->count_checkout_paths = !opts->quiet && !has_dash_dash;
if (!strcmp(arg, "-"))
builtin/checkout.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2d575a4f57..91b7c52396 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1085,7 +1085,9 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
if (more == 1)
describe_one_orphan(&sb, last);
else
- strbuf_addf(&sb, _(" ... and %d more.\n"), more);
+ strbuf_addf(&sb, Q_(" ... and %d more.\n",
+ " ... and %d more.\n",
+ more), more);
}
fprintf(stderr,
@@ -1489,7 +1491,9 @@ static int parse_branchname_arg(int argc, const char **argv,
else if (dash_dash_pos == 1)
has_dash_dash = 1; /* case (3) or (1) */
else if (dash_dash_pos >= 2)
- die(_("only one reference expected, %d given."), dash_dash_pos);
+ die(Q_("only one reference expected, %d given.",
+ "only one reference expected, %d given.",
+ dash_dash_pos), dash_dash_pos);
opts->count_checkout_paths = !opts->quiet && !has_dash_dash;
if (!strcmp(arg, "-"))
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Outreachy PATCH v2] checkout: use Q_() for messages with counts
2026-10-22 0:48 ` [Outreachy PATCH v2] checkout: use Q_() for messages with counts Tanga Joris
@ 2026-10-23 17:55 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2026-10-23 17:55 UTC (permalink / raw)
To: Tanga Joris
Cc: git, christian.couder, siddharthasthana31, kaartic.sivaraam,
usmanakinyemi202, taahol, ibnmuhyideen95
Tanga Joris <tangajoris@gmail.com> writes:
> - Also converted "only one reference expected, %d given.",
> as discussed by Tuomas in Mudi's thread.
>
> Interdiff against v1:
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 49239f029f..91b7c52396 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -1491,7 +1491,9 @@ static int parse_branchname_arg(int argc, const char **argv,
> else if (dash_dash_pos == 1)
> has_dash_dash = 1; /* case (3) or (1) */
> else if (dash_dash_pos >= 2)
> - die(_("only one reference expected, %d given."), dash_dash_pos);
> + die(Q_("only one reference expected, %d given.",
> + "only one reference expected, %d given.",
> + dash_dash_pos), dash_dash_pos);
> opts->count_checkout_paths = !opts->quiet && !has_dash_dash;
>
> if (!strcmp(arg, "-"))
>
> builtin/checkout.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Looks good to me. Will queue. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-23 17:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 2:21 [Outreachy PATCH] checkout: use Q_() for the "... and %d more" message Tanga Joris
2026-10-21 18:04 ` Junio C Hamano
2026-10-21 21:04 ` Tanga Joris
2026-10-22 0:48 ` [Outreachy PATCH v2] checkout: use Q_() for messages with counts Tanga Joris
2026-10-23 17:55 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox