All of lore.kernel.org
 help / color / mirror / Atom feed
* [GSoC PATCH] add-patch: use Q_() for split hunk translation
@ 2026-11-10 19:38 aeron-gh
  2026-11-20 10:33 ` [GSoC PATCH v2] " Abhishek Agarwal
  0 siblings, 1 reply; 3+ messages in thread
From: aeron-gh @ 2026-11-10 19:38 UTC (permalink / raw)
  To: git; +Cc: aeron-gh, Rubén Justo, Junio C Hamano, Patrick Steinhardt

The "Split into %d hunks." message uses _(), which provides
the same translation for every number. The Polish translation
shows "2 skrawków", but the correct form is "2 skrawki".
Numbers 2 and 5 need different plural forms.

Use Q_() with singular and plural forms, passing
splittable_into as the count. This lets translators provide
the correct plural forms while keeping the English output
unchanged.

Signed-off-by: aeron-gh <agab0323@gmail.com>
---
This patch is part of my GSoC 2027 microproject. Mahmoud
announced this issue in March, but no patch followed:
https://lore.kernel.org/git/CAC5WPUdYxm-7Pjq4oAddLKXjSa7B0YdK8ashyeR9vhCQt+wvPA@mail.gmail.com/

 add-patch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/add-patch.c b/add-patch.c
index f27edcbe8d..4e75e2ceda 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1942,7 +1942,9 @@ static size_t patch_update_file(struct add_p_state *s,
 			} else if (!split_hunk(s, file_diff,
 					     hunk - file_diff->hunk)) {
 				color_fprintf_ln(stdout, s->cfg.header_color,
-						 _("Split into %d hunks."),
+						 Q_("Split into %d hunk.",
+						    "Split into %d hunks.",
+						    splittable_into),
 						 (int)splittable_into);
 				rendered_hunk_index = -1;
 			}
-- 
2.56.0


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

* [GSoC PATCH v2] add-patch: use Q_() for split hunk translation
  2026-11-10 19:38 [GSoC PATCH] add-patch: use Q_() for split hunk translation aeron-gh
@ 2026-11-20 10:33 ` Abhishek Agarwal
  2026-12-02 16:13   ` Abhishek Agarwal
  0 siblings, 1 reply; 3+ messages in thread
From: Abhishek Agarwal @ 2026-11-20 10:33 UTC (permalink / raw)
  To: git; +Cc: Rubén Justo, Junio C Hamano, Patrick Steinhardt

The "Split into %d hunks." message uses _(), so a translation can
have only one form for every count. Some languages need more than
that. In Polish, 2 and 5 take different plural forms: the current
translation "Podzielono na %d skrawków" uses the form for 5, so a
split into 2 hunks reads "2 skrawków" instead of "2 skrawki".

Use Q_() and pass splittable_into as the count, so that gettext can
pick the form that fits the number.

Translators of a language with just a singular and a plural form,
such as German, now have to translate this message twice. In
exchange, translators of languages that need different forms for
"2 hunks" and "5 hunks" can get them right.

Signed-off-by: Abhishek Agarwal <agab0323@gmail.com>
---

Notes:
    Changes since v1:
    
     - Replaced the last sentence ("keeping the English output
       unchanged") with the trade-off for translators, as Junio
       suggested for a similar patch [1].
     - Author and sign-off now use my real name instead of "aeron-gh".
     - Rebased on current master. No code change.
    
    The count is always 2 or more here, because "s" is only offered
    when hunk->splittable_into > 1, so English never shows the
    singular string. Q_() still needs it, and translators fill in
    their own forms for the counts that do occur.
    
    [1] https://lore.kernel.org/git/xmqqv76vnd5h.fsf@gitster.g/

 add-patch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/add-patch.c b/add-patch.c
index f27edcbe8d..4e75e2ceda 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1942,7 +1942,9 @@ static size_t patch_update_file(struct add_p_state *s,
 			} else if (!split_hunk(s, file_diff,
 					     hunk - file_diff->hunk)) {
 				color_fprintf_ln(stdout, s->cfg.header_color,
-						 _("Split into %d hunks."),
+						 Q_("Split into %d hunk.",
+						    "Split into %d hunks.",
+						    splittable_into),
 						 (int)splittable_into);
 				rendered_hunk_index = -1;
 			}
-- 
2.56.0


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

* Re: [GSoC PATCH v2] add-patch: use Q_() for split hunk translation
  2026-11-20 10:33 ` [GSoC PATCH v2] " Abhishek Agarwal
@ 2026-12-02 16:13   ` Abhishek Agarwal
  0 siblings, 0 replies; 3+ messages in thread
From: Abhishek Agarwal @ 2026-12-02 16:13 UTC (permalink / raw)
  To: git; +Cc: Rubén Justo, Junio C Hamano, Patrick Steinhardt,
	Phillip Wood

Hi,

A gentle ping on this patch, in case it got buried. It still applies
cleanly to current master (566b6997dd).

In short: "git add -p" prints "Split into %d hunks." through _(), so
a language like Polish cannot use the right plural form for the
count. The patch switches the message to Q_(). v2 only changed the
commit message and my name; the code is the same as v1.

Adding Phillip to Cc, as he has worked on "add -p" a lot.

I know the release is close, so there is no hurry.

Thanks,
Abhishek

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

end of thread, other threads:[~2026-12-02 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 19:38 [GSoC PATCH] add-patch: use Q_() for split hunk translation aeron-gh
2026-11-20 10:33 ` [GSoC PATCH v2] " Abhishek Agarwal
2026-12-02 16:13   ` Abhishek Agarwal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.