As part of the RL10N project (https://github.com/RL10N), I've been asking lots of speakers of languages other than English about how useful it would be to have error messages translated into other languages.
One piece of opposition I've heard is that if you don't understand an error message, you need to type the message into an internet search engine, and you get better results if this message is in English.
That is, an optimal workflow is
1. See the error message in your language of choice, then
2. If it does not make sense, see it again in English.
To make part 2 possible, I want something like geterrmessage() that ignores the LANG environment variable.
# Set the messaging language to French
Sys.setenv(LANG = "fr")
# Throw an error
1 + @
# Retrieve the last error message
##  "Erreur : '@' inattendu(e) in \"1 + @\"\n"
I want to be able to get the error message in English using something like
##  "Error: unexpected '@' in \"1 + @\"\n"
I don't know how to get this functionality from an external package; I suspect it needs to be built into R at a low level.
This looks quite hard to do. R uses the gettext function from libintl to translate messages. These are often used as format strings rather than literal strings. The result after sprintf() (or a related function, I haven't looked) acts on the format string and other input data is used in the signalled error, and also saved in a buffer. geterrmessage() just reports what is in the buffer.
To do what you want, I think the following approach might work:
The translation macro _() (and related functions) would save the input string somewhere and return the translated string.
The error() function (and related functions) would produce the error message twice, once from the saved input string, once from the translated string. It
would generate the error using the translation, but save both of them.
The geterrmessage() function wouldn't need to change, but getenglisherrmessage()
would get its result from the other saved result.
This approach would fail in those rare(?) cases where several strings are translated, and something other than the last one is passed to the error() function. If these really are rare, they could conceivably all be modified to work.
This looks tricky, and might not succeed. It's certainly a lot of work. I'm not going to attempt it, but perhaps someone in RL10N would want to take it on.
Duncan M said everything: It would need quite a bit of work, and may be hard to achieve w/o breaking the current API.
We agree it is a reasonable wish, and so will be happy to collaborate with whoever is both capable and willing to do the work.
Till then, this is 'Wishlist'