On Sun, Nov 1, 2020 at 3:34 AM Euler Taveira <euler.tave...@2ndquadrant.com> wrote: > > No. The strings are specified in the appendStringInfo, hence you should add > _() > around the string to be translated. There is nothing to be translated if you > specify only the format identifier. You can always test if gettext extracts > the > string to be translated by executing 'make update-po' (after specifying > --enable-nls in the configure). Search for your string in one of the > generated > files (po/LL.po.new). >
Thanks a lot for the detailed explanation. > > You shouldn't split messages like that because not all languages have the same > order as English. Having said that you risk providing a nonsense translation > because someone decided to translate pieces of a sentence separately. > > + appendStringInfo(&logmsg, "replication "); > + > + appendStringInfo(&logmsg, "connection authorized: user=%s", > + port->user_name); > > This hunk will break translation. In Portuguese, the adjective "replication" > is > translated after the noun "connection". If you decided to keep this code as > is, > the printed message won't follow the grammar rules. You will have "replicação > conexão autorizada" instead of "conexão de replicação autorizada". The former > isn't grammatically correct. Avoid splitting sentences that are translated. > Agreed. Looks like we don't break localization rules if we have something like below, which is done in similar way for a log message in heap_vacuum_rel(): msgfmt = _("automatic aggressive vacuum to prevent wraparound of table \"%s.%s.%s\": index scans: %d\n"); if (am_walsender) appendStringInfo(&logmsg, _("replication connection authorized: user=%s"), port->user_name); else appendStringInfo(&logmsg, _("connection authorized: user=%s"), port->user_name); if (!am_walsender) appendStringInfo(&logmsg, _(" database=%s"), port->database_name); if (port->application_name != NULL) appendStringInfo(&logmsg, _(" application_name=%s"), port->application_name); #ifdef USE_SSL if (port->ssl_in_use) appendStringInfo(&logmsg, _(" SSL enabled (protocol=%s, cipher=%s, bits=%d, compression=%s)"), be_tls_get_version(port), be_tls_get_cipher(port), be_tls_get_cipher_bits(port), be_tls_get_compression(port) ? _("on") : _("off")); #endif #ifdef ENABLE_GSS if (be_gssapi_get_princ(port)) appendStringInfo(&logmsg, _(" GSS (authenticated=%s, encrypted=%s, principal=%s)"), be_gssapi_get_auth(port) ? _("yes") : _("no"), be_gssapi_get_enc(port) ? _("yes") : _("no"), be_gssapi_get_princ(port)); #endif ereport(LOG, errmsg_internal("%s", logmsg.data)); With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com