On Wed, 29 Jun 2022, Quentin Cosendey wrote:
>> What do people do about the what() strings in application exceptions?
>> Those are my only user-facing strings in my library. Is there a best
>> practice for exception strings that get translated by the client
>> application before logging or display?
> Don't translate output in log files. This will help users to search the error
> message in google.
If the ability to search things with Google is the priority, then arguably
one should not translate any messages in the application.
The point of localization is to show messages in the user's preferred
language, and leaving user-readable log messages unlocalized for the sake
of Google sounds suboptimal. After all, in some cases the user may not be
able to understand the untranslated source language.
What I would do, if googlability is considered important, is to prefix
each log message with a unique numeric code, something like: "E1234: out
of disk space".
> In theory, the non-technical user isn't supposed to ever see the contents of
This entirely depends on how the code uses exceptions. If we are talking
about exceptions thrown by the standard C++ library, then yes, those tend
to be about pretty fatal conditions, and should not occur during normal
operation. But one's own exceptions may well be used for regular error
handling and returning user-readable error messages.