mirror of
https://github.com/postgres/postgres.git
synced 2026-06-15 03:30:26 -04:00
Fix translatable string construction
In a few places, we were constructing translatable strings consisting of elements list by adding one element at a time and separately a comma. This is not great from a translation point of view, so rewrite to append the comma together with the corresponding element in one go. Author: Peter Smith <smithpb2250@gmail.com> Author: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://postgr.es/m/CAHut+Pvp7jYcaiZ3pXedXgLcWZWDBLXFUK05JtZpGv3Mj=UOjw@mail.gmail.com
This commit is contained in:
parent
7dd1532595
commit
3692a622d3
3 changed files with 24 additions and 26 deletions
|
|
@ -41,6 +41,10 @@ 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)
|
||||
|
|
@ -54,19 +58,21 @@ 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)
|
||||
appendStringInfo(dest, _("\"%s\""), pubname);
|
||||
else
|
||||
appendStringInfo(dest, _(", \"%s\""), pubname);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20607,18 +20607,11 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
|
|||
{
|
||||
char *pubname = get_publication_name(pubid, false);
|
||||
|
||||
if (!first)
|
||||
{
|
||||
/*
|
||||
* translator: This is a separator in a list of publication
|
||||
* names.
|
||||
*/
|
||||
appendStringInfoString(&pubnames, _(", "));
|
||||
}
|
||||
|
||||
if (first)
|
||||
appendStringInfo(&pubnames, _("\"%s\""), pubname);
|
||||
else
|
||||
appendStringInfo(&pubnames, _(", \"%s\""), pubname);
|
||||
first = false;
|
||||
|
||||
appendStringInfo(&pubnames, _("\"%s\""), pubname);
|
||||
}
|
||||
|
||||
ereport(ERROR,
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ static char *
|
|||
logicalrep_get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
|
||||
{
|
||||
StringInfoData attsbuf;
|
||||
int attcnt = 0;
|
||||
bool first = true;
|
||||
int i = -1;
|
||||
|
||||
Assert(!bms_is_empty(atts));
|
||||
|
|
@ -248,12 +248,11 @@ logicalrep_get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
|
|||
|
||||
while ((i = bms_next_member(atts, i)) >= 0)
|
||||
{
|
||||
attcnt++;
|
||||
if (attcnt > 1)
|
||||
/* translator: This is a separator in a list of entity names. */
|
||||
appendStringInfoString(&attsbuf, _(", "));
|
||||
|
||||
appendStringInfo(&attsbuf, _("\"%s\""), remoterel->attnames[i]);
|
||||
if (first)
|
||||
appendStringInfo(&attsbuf, _("\"%s\""), remoterel->attnames[i]);
|
||||
else
|
||||
appendStringInfo(&attsbuf, _(", \"%s\""), remoterel->attnames[i]);
|
||||
first = false;
|
||||
}
|
||||
|
||||
return attsbuf.data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue