Hi, 

On February 11, 2026 4:37:54 PM PST, Chao Li <[email protected]> wrote:
>Hi,
>
>The relevant code looks like this:
>```
>        msg_one = _("invalid page in block %u of relation \"%s\””);
>
>       ereport(elevel,
>           errcode(ERRCODE_DATA_CORRUPTED),
>           errmsg_internal(msg_one, first + first_off, rpath.str) :
>```
>
>Here, the string is first translated via _() and stored in msg_one, and then 
>passed to errmsg_internal(). However, according to the header comment of 
>errmsg_internal():
>```
>/*
>* errmsg_internal --- add a primary error message text to the current error
>*
>* This is exactly like errmsg() except that strings passed to errmsg_internal
>* are not translated, and are customarily left out of the
>* internationalization message dictionary. This should be used for "can't
>* happen" cases that are probably not worth spending translation effort on.
>* We also use this for certain cases where we *must* not try to translate
>* the message because the translation would fail and result in infinite
>* error recursion.
>*/
>int
>errmsg_internal(const char *fmt,...)
>```
>
>errmsg_internal() is explicitly intended for non-translatable, internal 
>messages. Passing an already translated string to it feels inconsistent with 
>its documented purpose.

I don't think it is - you want to translate just once. There are other places 
using that pattern. 


>In bufmgr.c, these corruption-related messages are clearly user-facing, so it 
>seems more appropriate to use errmsg() here instead of errmsg_internal(). If 
>my understanding is correct, the attached patch fixes the usages in bufmgr.c.
>
>This patch doesn't affect runtime behavior, but it avoids confusion for future 
>readers, and helps prevent similar misuse elsewhere.

You can't do that, because then the strings won't be recognized as translatable 
by the translation machinery.  The arguments to functions that take 
to-be-translated strings (like errmsg(..., ) or _(...) have to constants, so 
the strings can be extracted to then be translated.

Greetings, 

Andres
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Reply via email to