Re: [PATCH v2 2/7] strbuf: split out logic to humanise byte values
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 16, 2025, 04:37 UTC
- Message-ID
- <xmqqqzsv3uus.fsf@gitster.g>
- In-Reply-To
- <CANYiYbE3Tx6B5L5rEoDue7hTYzFGxw_qA-MRpC9RSxQ7HRczaw@mail.gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 26 quoted lines
> On Sat, Dec 13, 2025 at 6:37 AM Justin Tobler <jltobler@gmail.com> 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?
Punting is fine in this case, but in case a similar situation arises in real code, it would be better to establish a pattern we can follow.
Thanks.