public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Smith <[email protected]>
To: Álvaro Herrera <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Redundant/mis-use of _(x) gettext macro?
Date: Tue, 7 Apr 2026 15:05:51 +1000
Message-ID: <CAHut+Pui7RaQ8OfJEVn2ry-ykjnGc+3ujsFmcHDFw9FsXw_tRw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAHut+Pvp7jYcaiZ3pXedXgLcWZWDBLXFUK05JtZpGv3Mj=UOjw@mail.gmail.com>
<[email protected]>
On Wed, Apr 1, 2026 at 10:52 PM Álvaro Herrera <[email protected]> wrote:
>
> On 2026-Apr-01, Peter Smith wrote:
>
> > Hi.
> >
> > As originally reported [1] in the EXCEPT (TABLE ...) thread, I felt
> > the _() gettext macro is mis-used when it contains nothing but a
> > quoted format string.
>
> No, you feel wrong -- this is necessary so that the translator has
> control over the quoting style of a list of items. Not all translations
> use double quoting. Some examples from different language files:
>
> msgstr "unbekannte Komprimierungsoption: »%s«"
> msgstr "opción de compresión no reconocida: «%s»"
> msgstr "option de compression inconnue : « %s »"
> msgstr "tidak dapat menentukan encoding untuk lokal « %s » : codesetnya adalah « %s »"
>
The explanation [1] that even the comma separators and the quotes are
translatable parts of the message reminded me to revisit the
`GetPublicationsStr` function.
This function builds a comma-separated list of publication names.
It is called in 2 scenarios:
1. to construct a pubname list to be included in some SQL (here,
parameter quote_literal=true)
2. to construct a pubname list to be included in some error message
(here, parameter quote_literal=false).
In hindsight, it looks like this function has been broken since it was
originally implemented 4 yrs ago (8f2e2bb), because it does not allow
translation of commas and quotes when the result is being used for
error messages.
PSA a patch to fix that.
======
[1] https://www.postgresql.org/message-id/202604011144.jeo56tazdx6z%40alvherre.pgsql
Kind Regards,
Peter Smith.
Fujitsu Australia
Attachments:
[application/octet-stream] v1-0001-GetPublicationsStr-i18n-support.patch (1.2K, 2-v1-0001-GetPublicationsStr-i18n-support.patch)
download | inline diff:
From cd09ae7e4c18bfcb1b6522ec1aa16cfa3b5f502e Mon Sep 17 00:00:00 2001
From: Peter Smith <[email protected]>
Date: Tue, 7 Apr 2026 14:45:11 +1000
Subject: [PATCH v1] GetPublicationsStr i18n support
---
src/backend/catalog/pg_subscription.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 5a733585490..8b31c487dba 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -54,19 +54,22 @@ GetPublicationsStr(List *publications, StringInfo dest, bool quote_literal)
{
char *pubname = strVal(lfirst(lc));
- if (first)
- first = false;
- else
- appendStringInfoString(dest, ", ");
-
if (quote_literal)
+ {
+ if (!first)
+ appendStringInfoString(dest, ", ");
+
appendStringInfoString(dest, quote_literal_cstr(pubname));
+ }
else
{
- appendStringInfoChar(dest, '"');
- appendStringInfoString(dest, pubname);
- appendStringInfoChar(dest, '"');
+ if (!first)
+ appendStringInfoString(dest, _(", "));
+
+ appendStringInfo(dest, _("\"%s\""), pubname);
}
+
+ first = false;
}
}
--
2.47.3
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: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Redundant/mis-use of _(x) gettext macro?
In-Reply-To: <CAHut+Pui7RaQ8OfJEVn2ry-ykjnGc+3ujsFmcHDFw9FsXw_tRw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox