> On 19 Sep 2025, at 08:56, Chao Li <[email protected]> wrote: >> On Sep 19, 2025, at 14:45, Florents Tselai <[email protected]> wrote:
>>> This is a normal usage that injects sub-strings based on condition. >>> However, PG doesn’t like that, see here: >>> https://www.postgresql.org/docs/devel/nls-programmer.html#NLS-GUIDELINES >> >> Well, that’s a very interesting catch. >> I’ll let a comitter confirm & advise. > > I got to know this because once I reviewed a Tom Lane’s patch, it had the > similarly situation, but Tom wrote code like: > > ``` > If (something) > Ereport(“function xxx”) > Else > Ereport(“procedure xxx”) > ``` > > I raised a comment to suggest avoid duplicate code in the way like your code > do, and I got a response with “no” and the link. Tom is right (unsurprisingly) here, since "function" and "procedure" are terms which are translated and depending on which is used it may change the sentence structure in the target language. In this case we inject a name which isn't to be translated, and that will instead help the translator since they otherwise need to translate two strings instead of just one (and they can move the %s to position the injected name into the right place according to grammar rules). -- Daniel Gustafsson
