Thread View: linux.kernel.git
2 messages
2 total messages
Started by aeron-gh
Tue, 10 Nov 2026 19:38
[GSoC PATCH] add-patch: use Q_() for split hunk translation
Author: aeron-gh
Date: Tue, 10 Nov 2026 19:38
Date: Tue, 10 Nov 2026 19:38
37 lines
11749 bytes
11749 bytes
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
[GSoC PATCH v2] add-patch: use Q_() for split hunk translation
Author: Abhishek Agarwal
Date: Fri, 20 Nov 2026 10:33
Date: Fri, 20 Nov 2026 10:33
54 lines
12601 bytes
12601 bytes
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
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