Thread View: linux.kernel.git
3 messages
3 total messages
Started by "Raj Ojha via GitGitGadget"
Thu, 15 Oct 2026 09:54
[PATCH] describe: use Q_() for pluralization of commit and tag counts
Author: "Raj Ojha via GitGitGadget"
Date: Thu, 15 Oct 2026 09:54
Date: Thu, 15 Oct 2026 09:54
74 lines
10369 bytes
10369 bytes
From: Raj Ojha <rajojha047@gmail.com>
In `describe_commit()`, debug messages print the number of commits
traversed and the number of candidate tags found using basic `_()`
localization format strings:
_("traversed %lu commits\n")
_("found %i tags; gave up search at %s\n")
Because these messages display an integer count of items, using `_()`
fails to account for languages whose pluralization rules differ from
English (such as languages with multiple plural forms).
Replace these calls with `Q_()` to allow gettext (`ngettext()`) to choose
the grammatically appropriate singular or plural string depending on the
integer count.
Signed-off-by: Raj Ojha <rajojha047@gmail.com>
---
describe: use Q_() for pluralization of commit and tag counts
In describe_commit(), debug messages print the number of commits
traversed and the number of candidate tags found using basic _()
localization format strings:
_("traversed %lu commits\n")
_("found %i tags; gave up search at %s\n")
Because these messages display an integer count of items, using _()
fails to account for languages whose pluralization rules differ from
English (such as languages with multiple plural forms).
Replace these calls with Q_() to allow gettext (ngettext()) to choose
the grammatically appropriate singular or plural string depending on the
integer count.
Signed-off-by: Raj Ojha rajojha047@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2257%2FRajojha-1%2Fdescribe-q-pluralize-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2257/Rajojha-1/describe-q-pluralize-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2257
builtin/describe.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index c0abc931a5..1a7317c811 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -481,10 +481,16 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
label_width, _(prio_names[t->name->prio]),
t->depth, t->name->path);
}
- fprintf(stderr, _("traversed %lu commits\n"), seen_commits);
+ fprintf(stderr,
+ Q_("traversed %lu commit\n",
+ "traversed %lu commits\n",
+ seen_commits),
+ seen_commits);
if (gave_up_on) {
fprintf(stderr,
- _("found %i tags; gave up search at %s\n"),
+ Q_("found %i tag; gave up search at %s\n",
+ "found %i tags; gave up search at %s\n",
+ max_candidates),
max_candidates,
oid_to_hex(&gave_up_on->object.oid));
}
base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd
--
gitgitgadget
Re: [PATCH] describe: use Q_() for pluralization of commit and tag counts
Author: Junio C Hamano
Date: Fri, 16 Oct 2026 15:51
Date: Fri, 16 Oct 2026 15:51
83 lines
12562 bytes
12562 bytes
"Raj Ojha via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Raj Ojha <rajojha047@gmail.com>
>
> In `describe_commit()`, debug messages print the number of commits
> traversed and the number of candidate tags found using basic `_()`
> localization format strings:
>
> _("traversed %lu commits\n")
> _("found %i tags; gave up search at %s\n")
>
> Because these messages display an integer count of items, using `_()`
> fails to account for languages whose pluralization rules differ from
> English (such as languages with multiple plural forms).
>
> Replace these calls with `Q_()` to allow gettext (`ngettext()`) to choose
> the grammatically appropriate singular or plural string depending on the
> integer count.
>
> Signed-off-by: Raj Ojha <rajojha047@gmail.com>
> ---
Is this convergent evolution or something? The similarity to
https://lore.kernel.org/git/20261013204351.428800-1-antekborowski11@gmail.com/
is striking.
It's not like anybody who sent a change on a piece of code
automatically owns the area to be improved, but we would love to see
more collaboration and a better use of the lore archive to find
similar effort being made before people send patches.
https://lore.kernel.org/git/?q=describe+Q_
> describe: use Q_() for pluralization of commit and tag counts
>
> In describe_commit(), debug messages print the number of commits
> traversed and the number of candidate tags found using basic _()
> localization format strings:
>
> _("traversed %lu commits\n")
> _("found %i tags; gave up search at %s\n")
>
>
> Because these messages display an integer count of items, using _()
> fails to account for languages whose pluralization rules differ from
> English (such as languages with multiple plural forms).
>
> Replace these calls with Q_() to allow gettext (ngettext()) to choose
> the grammatically appropriate singular or plural string depending on the
> integer count.
You do not want to repeat your log message below the three-dash
line. It wastes everybody's time.
> diff --git a/builtin/describe.c b/builtin/describe.c
> index c0abc931a5..1a7317c811 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -481,10 +481,16 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
> label_width, _(prio_names[t->name->prio]),
> t->depth, t->name->path);
> }
> - fprintf(stderr, _("traversed %lu commits\n"), seen_commits);
> + fprintf(stderr,
> + Q_("traversed %lu commit\n",
> + "traversed %lu commits\n",
> + seen_commits),
> + seen_commits);
> if (gave_up_on) {
> fprintf(stderr,
> - _("found %i tags; gave up search at %s\n"),
> + Q_("found %i tag; gave up search at %s\n",
> + "found %i tags; gave up search at %s\n",
> + max_candidates),
> max_candidates,
> oid_to_hex(&gave_up_on->object.oid));
> }
Both the log message and patch text look cleanly done.
Thanks.
Re: [PATCH] describe: use Q_() for pluralization of commit and tag counts
Author: Junio C Hamano
Date: Sat, 17 Oct 2026 16:27
Date: Sat, 17 Oct 2026 16:27
24 lines
10395 bytes
10395 bytes
Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
> On Thu, Oct 15, 2026 at 09:54:29AM +0000, Raj Ojha via GitGitGadget wrote:
>>In `describe_commit()`, debug messages print the number of commits
>>traversed and the number of candidate tags found using basic `_()`
>>localization format strings:
>>
>> _("traversed %lu commits\n")
>> _("found %i tags; gave up search at %s\n")
>>
> i wonder why _debug_ messages are i18n'd in the first place? their
> target audience would usually be the git developers. or is this just a
> misnomer?
Funny that great minds think alike.
https://lore.kernel.org/git/20261014092923.GA1344504@coredump.intra.peff.net/
which led to
https://lore.kernel.org/git/20261016185418.162998-1-antekborowski11@gmail.com/
;-)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads