Make property graph object descriptions better translatable

getObjectDescription() currently constructs property graph-related
object descriptions incrementally with appendStringInfo().  This
effectively fixes the word order in English, which makes the messages
difficult to translate naturally into languages such as Japanese.

Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/20260528.121622.1662808269492494574.horikyota.ntt%40gmail.com
This commit is contained in:
Peter Eisentraut 2026-07-03 23:32:20 +02:00
parent b82d69abf6
commit e0ff7fd9aa

View file

@ -4083,6 +4083,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{
HeapTuple tup;
Form_pg_propgraph_element pgeform;
StringInfoData rel;
tup = SearchSysCache1(PROPGRAPHELOID, ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tup))
@ -4095,16 +4096,17 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
pgeform = (Form_pg_propgraph_element) GETSTRUCT(tup);
if (pgeform->pgekind == PGEKIND_VERTEX)
/* translator: followed by, e.g., "property graph %s" */
appendStringInfo(&buffer, _("vertex %s of "), NameStr(pgeform->pgealias));
else if (pgeform->pgekind == PGEKIND_EDGE)
/* translator: followed by, e.g., "property graph %s" */
appendStringInfo(&buffer, _("edge %s of "), NameStr(pgeform->pgealias));
else
appendStringInfo(&buffer, "??? element %s of ", NameStr(pgeform->pgealias));
getRelationDescription(&buffer, pgeform->pgepgid, false);
initStringInfo(&rel);
getRelationDescription(&rel, pgeform->pgepgid, false);
if (pgeform->pgekind == PGEKIND_VERTEX)
appendStringInfo(&buffer, _("vertex %s of %s"), NameStr(pgeform->pgealias), rel.data);
else if (pgeform->pgekind == PGEKIND_EDGE)
appendStringInfo(&buffer, _("edge %s of %s"), NameStr(pgeform->pgealias), rel.data);
else
appendStringInfo(&buffer, "??? element %s of %s", NameStr(pgeform->pgealias), rel.data);
pfree(rel.data);
ReleaseSysCache(tup);
break;
}
@ -4131,9 +4133,10 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
pgelform = (Form_pg_propgraph_element_label) GETSTRUCT(tuple);
appendStringInfo(&buffer, _("label %s of "), get_propgraph_label_name(pgelform->pgellabelid));
ObjectAddressSet(oa, PropgraphElementRelationId, pgelform->pgelelid);
appendStringInfoString(&buffer, getObjectDescription(&oa, false));
appendStringInfo(&buffer, _("label %s of %s"),
get_propgraph_label_name(pgelform->pgellabelid),
getObjectDescription(&oa, false));
table_close(rel, AccessShareLock);
break;
@ -4143,6 +4146,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{
HeapTuple tuple;
Form_pg_propgraph_label pglform;
StringInfoData rel;
tuple = SearchSysCache1(PROPGRAPHLABELOID, ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tuple))
@ -4154,9 +4158,12 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
pglform = (Form_pg_propgraph_label) GETSTRUCT(tuple);
/* translator: followed by, e.g., "property graph %s" */
appendStringInfo(&buffer, _("label %s of "), NameStr(pglform->pgllabel));
getRelationDescription(&buffer, pglform->pglpgid, false);
initStringInfo(&rel);
getRelationDescription(&rel, pglform->pglpgid, false);
appendStringInfo(&buffer, _("label %s of %s"), NameStr(pglform->pgllabel), rel.data);
pfree(rel.data);
ReleaseSysCache(tuple);
break;
}
@ -4183,9 +4190,11 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
plpform = (Form_pg_propgraph_label_property) GETSTRUCT(tuple);
appendStringInfo(&buffer, _("property %s of "), get_propgraph_property_name(plpform->plppropid));
ObjectAddressSet(oa, PropgraphElementLabelRelationId, plpform->plpellabelid);
appendStringInfoString(&buffer, getObjectDescription(&oa, false));
appendStringInfo(&buffer, _("property %s of %s"),
get_propgraph_property_name(plpform->plppropid),
getObjectDescription(&oa, false));
table_close(rel, AccessShareLock);
break;
@ -4195,6 +4204,7 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
{
HeapTuple tuple;
Form_pg_propgraph_property pgpform;
StringInfoData rel;
tuple = SearchSysCache1(PROPGRAPHPROPOID, ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(tuple))
@ -4206,9 +4216,12 @@ getObjectDescription(const ObjectAddress *object, bool missing_ok)
pgpform = (Form_pg_propgraph_property) GETSTRUCT(tuple);
/* translator: followed by, e.g., "property graph %s" */
appendStringInfo(&buffer, _("property %s of "), NameStr(pgpform->pgpname));
getRelationDescription(&buffer, pgpform->pgppgid, false);
initStringInfo(&rel);
getRelationDescription(&rel, pgpform->pgppgid, false);
appendStringInfo(&buffer, _("property %s of %s"), NameStr(pgpform->pgpname), rel.data);
pfree(rel.data);
ReleaseSysCache(tuple);
break;
}