Re: Redundant/mis-use of _(x) gettext macro? - Mailing list pgsql-hackers

From Peter Smith
Subject Re: Redundant/mis-use of _(x) gettext macro?
Date
Msg-id CAHut+Pu7LWQB+m9HTf4nf3BQu8bC_-N5c=kuOf=EHHZE_Ctj9Q@mail.gmail.com
Whole thread
In response to Re: Redundant/mis-use of _(x) gettext macro?  (Álvaro Herrera <alvherre@kurilemu.de>)
Responses Re: Redundant/mis-use of _(x) gettext macro?
List pgsql-hackers
On Thu, Apr 23, 2026 at 7:25 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> On 2026-Apr-23, Peter Smith wrote:
>
> > v2 removes translation of the comma separator, due to the discussion
> > over at [1].
>
> Hmm, at least Japanese uses a different character for commas, and
> apparently French likes to add a space, so I think this is a bad move.
> I think we could handle these things by including the comma together
> with the literal in each element of the list being constructed, as in
> the attached.
>

OK. Including the comma within a larger translated string seems like a
better idea.

Since you now have the list `length`, I wondered why not simplify
further to use list_nth indexing? Then you can remove
`foreach_current_index` and `lc`.

PSA.

~~~~

Also, why did you choose to implement `last` versus `first` logic?
e.g. How about this?

------
GetPublicationsStr(List *publications, StringInfo dest, bool quote_literal)
{
    ListCell   *lc;
    bool        first = true;

    Assert(publications != NIL);

    foreach(lc, publications)
    {
        char       *pubname = strVal(lfirst(lc));

        if (quote_literal)
        {
            if (!first)
                appendStringInfoString(dest, ", ");
            appendStringInfoString(dest, quote_literal_cstr(pubname));
        }
        else
        {
            if (first)
                appendStringInfo(dest, _("\"%s\""), pubname);
            else
                appendStringInfo(dest, _(", \"%s\""), pubname);
        }

        first = false;
    }
}
------

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment

pgsql-hackers by date:

Previous
From: "Masashi Kamura (Fujitsu)"
Date:
Subject: RE: ECPG: inconsistent behavior with the document in “GET/SET DESCRIPTOR.”
Next
From: Fujii Masao
Date:
Subject: Re: pg_test_timing: fix unit typo and widen diff type