pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: Peter Smith <smithpb2250@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Redundant/mis-use of _(x) gettext macro?
Date: Thu, 23 Apr 2026 11:25:07 +0200
Message-ID: <aeniYoOwCQmtWtQW@alvherre.pgsql> (raw)
In-Reply-To: <CAHut+PuD2pGMEKmk2dFA+guzxBEOas5+=LAm5E+SM2LU35KOnQ@mail.gmail.com>

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.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/

Attachments:

0001-change-translation-markers-in-GetPublicationsStr.patch (text/x-diff, 1.8K) download From 8b92dce1a64d623e76019a4b83576458defd63e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <alvherre@kurilemu.de> Date: Thu, 23 Apr 2026 11:10:54 +0200 Subject: [PATCH] change translation markers in GetPublicationsStr --- src/backend/catalog/pg_subscription.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index 1f1fdc75af6..d1e2e9de468 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -41,31 +41,36 @@ static List *textarray_to_stringlist(ArrayType *textarray); /* * Add a comma-separated list of publication names to the 'dest' string. + * + * If quote_literal is true, the returned list can be used to construct an SQL + * command, thus no translation is applied. Otherwise, the string can be used + * to create a user-facing message, so translatable quote marks are added. */ void GetPublicationsStr(List *publications, StringInfo dest, bool quote_literal) { ListCell *lc; - bool first = true; + int length = list_length(publications); Assert(publications != NIL); foreach(lc, publications) { char *pubname = strVal(lfirst(lc)); - - if (first) - first = false; - else - appendStringInfoString(dest, ", "); + bool last = foreach_current_index(lc) >= length - 1; if (quote_literal) + { appendStringInfoString(dest, quote_literal_cstr(pubname)); + if (!last) + appendStringInfoString(dest, ", "); + } else { - appendStringInfoChar(dest, '"'); - appendStringInfoString(dest, pubname); - appendStringInfoChar(dest, '"'); + if (last) + appendStringInfo(dest, _("\"%s\""), pubname); + else + appendStringInfo(dest, _("\"%s\", "), pubname); } } } -- 2.47.3

view thread (18+ messages)  latest in thread

Message-ID: <aeniYoOwCQmtWtQW@alvherre.pgsql>
Permalink:  ../aeniYoOwCQmtWtQW@alvherre.pgsql/
Also on:    postgresql.org/message-id/aeniYoOwCQmtWtQW@alvherre.pgsql

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@kurilemu.de, smithpb2250@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Redundant/mis-use of _(x) gettext macro?
  In-Reply-To: <aeniYoOwCQmtWtQW@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox