We've had a long standing problem since Moodle 2.0 where by the default behaviour of moodle_exception is to translate the errorcode passed to it.
I really don't like this situation because:
- Its wasting translators time, translating obscure exception messages. Our translators time is precious, we shouldn't be wasting it on 'exceptional' situations.
- Incomprehensible error messages for multilingual sites. If the admins of a Moodle site only speak one language and the error message is in another, the error message printed in the log is the language of the user who experienced it
- Non-searchable error messages presented to users. If an error message is in a different language to english, its often impossible to search for on google or docs.moodle.org
I would like to see us change this behaviour so that we don't encourage the creation of new strings with exceptions.
I haven't thought particularly hard about solutions in code, but I would like to get discussion about this problem and potential solutions.
My thought is that we could have a default exception handler that handles the translation so that:
- Webpages do something like: 'An error occurred: ($a)' error message which is translated (with $a being the english 'errorcode'). Perhaps adding the ability for an exception class to be more specific
- Web services/CLI scripts do english errors