0001-change-translation-markers-in-GetPublicationStr-PS.diff
application/octet-stream
Filename: 0001-change-translation-markers-in-GetPublicationStr-PS.diff
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch 0001
| File | + | − |
|---|---|---|
| src/backend/catalog/pg_subscription.c | 16 | 12 |
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 5a733585490..7749ec380de 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -41,31 +41,35 @@ 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)
+ for (int i = 0; i < length; i++)
{
- char *pubname = strVal(lfirst(lc));
-
- if (first)
- first = false;
- else
- appendStringInfoString(dest, ", ");
+ char *pubname = strVal(list_nth(publications, i));
+ bool last = i >= 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);
}
}
}