Re: Internationalized error messages - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Re: Internationalized error messages |
Date | |
Msg-id | 7100.984157522@sss.pgh.pa.us Whole thread Raw |
In response to | Re: Internationalized error messages (Peter Eisentraut <peter_e@gmx.net>) |
Responses |
Re: Internationalized error messages
Re: Internationalized error messages Re: Internationalized error messages Re: Internationalized error messages |
List | pgsql-hackers |
Peter Eisentraut <peter_e@gmx.net> writes: > Let's say "type mismatch error", code 2200G acc. to SQL. At one place in > the source you write > elog(ERROR, "2200G", "type mismatch in CASE expression (%s vs %s)", ...); > Elsewhere you'd write > elog(ERROR, "2200G", "type mismatch in argument %d of function %s, > expected %s, got %s", ...); Okay, so your notion of an error code is not a localizable entity at all, it's something for client programs to look at. Now I get it. I object to writing "2200G" however, because that has no mnemonic value whatever, and is much too easy to get wrong. How about elog(ERROR, ERR_TYPE_MISMATCH, "type mismatch in argument %d of function %s, expected %s, got %s", ...); where ERR_TYPE_MISMATCH is #defined as "2200G" someplace? Or for that matter #defined as "TYPE_MISMATCH"? Content-free numeric codes are no fun to use on the client side either... > Gettext takes care of this. In the source you'd write > elog(ERROR, "2200G", gettext("type mismatch in CASE expression (%s vs %s)"), > string, string); Duh. For some reason I was envisioning the localization substitution as occurring on the client side, but of course we'd want to do it on the server side, and before parameters are substituted into the message. Sorry for the noise. I am not sure we can/should use gettext (possible license problems?), but certainly something like this could be cooked up. >> Sorry, I meant that as an example of the "secondary message string", but >> it's a pretty lame example... > I guess I'm not sold on the concept of primary and secondary message > strings. If the primary message isn't good enough you better fix that. The motivation isn't so much to improve on the primary message as to reduce the number of distinct strings that really need to be translated. Remember all those internal "can't happen" errors. If we have only one message component then the translator is faced with a huge pile of internal messages and not a lot of gain from translating them. If there's a primary and secondary component then all the internal messages can share the same primary component ("Internal error, please file a bug report"). Now the translator translates that one message, and can ignore the many secondary-component messages with a clear conscience. (Of course, he can translate those too if he really wants to, but the point is that he doesn't *have* to do it to attain reasonably friendly behavior.) Perhaps another way to look at it is that we have a bunch of errors that are user-oriented (ie, relate pretty directly to something the user did wrong) and another bunch that are system-oriented (relate to internal problems, such as consistency check failures or violations of internal APIs). We want to provide localized translations of the first set, for sure. I don't think we need localized translations of the second set, so long as we have some sort of "covering message" that can be localized for them. Maybe instead of "primary" and "secondary" strings for a single error, we ought to distinguish these two categories of error and plan different localization strategies for them. regards, tom lane
pgsql-hackers by date: