From: Jiang Xin Date: Tue, 16 Dec 2025 06:18:06 GMT Subject: Re: [PATCH v2 2/7] strbuf: split out logic to humanise byte values Message-ID: In-Reply-To: On Tue, Dec 16, 2025 at 12:37 PM Junio C Hamano wrote: > > Jiang Xin writes: > > > On Sat, Dec 13, 2025 at 6:37 AM Justin Tobler wrote: > >> + return humanise_rate ? > >> + /* TRANSLATORS: IEC 80000-13:2008 byte/second */ > >> + xstrfmt(Q_("byte/s", "bytes/s", bytes)) : > >> + /* TRANSLATORS: IEC 80000-13:2008 byte */ > >> + xstrfmt(Q_("byte", "bytes", bytes)); > > > > We have already defined "byte" as a 10n string without plural forms in the > > file "t/helper/test-simple-ipc.c" via commit 36a7eb6876 (t0052: add simple-ipc > > tests and t/helper/test-simple-ipc tool, 2021-03-22 10:29:48 +0000). > > > > OPT_STRING(0, "byte", &bytevalue, N_("byte"), N_("ballast character")), > > > > The newly introduced usage of "byte" is now marked as having a plural form > > (via Q_("byte", "bytes", bytes)), which causes a conflict. This results in make > > pot failing with the following error: > > > > msgcat: msgid 'byte' is used without plural and with plural. > > > > This happens because gettext requires that a given msgid be treated > > consistently—either exclusively as a singular string or as part of a plural > > construct—but not both. > > > > To resolve this conflict, we can unmark the singular "byte" in > > t/helper/test-simple-ipc.c, allowing it to reuse the translation from the > > plural-form definition of "byte". > > I learned a new thing today and am happy :). > > But how does one "unmark" the singular "byte" there, exactly? > > Would something like this ... > > OPT_STRING(0, "byte", &bytevalue, Q_("byte", "bytes", 1), N_("ballast character")), > > ... a good idea, to "mark" it as a countable noun that has a plural > form? > > Or did you mean that we can simply drop N_() around it, i.e., > N_("byte") -> "byte", to discard the i18n, because it merely is a > test helper? I prefer dropping N_() for "byte" in "t/helper/test-simple-ipc.c", and the i18n for the test helper will continue to work as before if we also mark the plural-form of "byte" in this patch series. (i.e., drop the N_() for "byte" in the test helper in this patch.) This is because N_() is a macro that does not invoke any gettext function, only returns msgid as in gettext.h: #define N_(msgid) msgid And the actual translation for the msgid (the argh field of an option) occurs later by calling: opts->argh ? _(opts->argh) : _("...") in "parse-options.c". However, replacing N_() with Q_() would cause the string to be processed by gettext twice: once at runtime via Q_(), and again when _(opts->argh) is evaluated.