Page MenuHomePhorge

Logged exceptions/errors should ignore user's language setting and be always in English
Open, Needs TriagePublic

Description

Looking at error logs and seeing error messages not in English (due to Phorge logging in whatever language setting that user reaching an error has set for themselves) makes debugging more cumbersome if you first need to look up the corresponding English string in the translations.

For example, I'd prefer to see
You must set a name or a name prefix!
in our logs when user activities trigger https://we.phorge.it/source/phorge/browse/master/src/applications/diffusion/query/DiffusionSymbolQuery.php$148 instead of
Vous devez d\xc3\xa9finir un nom ou un pr\xc3\xa9fixe de nom\xe2\x80\xaf!

Event Timeline

Ideally strings not shown to the user would also not be wrapped in pht(...) at all to avoid wasting translator's time. This is contrary to the documentation inherited from old upstream at https://we.phorge.it/book/contrib/article/internationalization/, though,

Ideally strings not shown to the user would also not be wrapped in pht(...) at all to avoid wasting translator's time.

Notice that the error message here is expected to be shown to the user (in their own language) so this isn't the case here.

pht() also does some escaping, formatting, and other safety related stuff, and it's more convenient to use the same methods for all human-readable messages rather then "user-readable" vs "admin-readable".


But yes, the logs should not show up in the language of the user that triggered the exception - they should either stay proto-English, or translated to some selected system level language.

From a technical POV, I think we can't do that right now because pht() returns a plain string. We talked about making pht() return some kind of a lazy string-like object, so that translations (and formatting) can be avoided for strings that are not shown, and this might be another good use-case for that. I can't find the old discussion right now.

But also, I'd expect the log to come with a stacktrace that points to a useful line in the code?