A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Ability to choose language for javascript error messages

dylang
2015-01-14

Situation

Developers record client-side Javascript errors using a services like Sentry, TrackJS, Airbreak, Rollbar, New Relic and many others. These services listen for error events and send the error message and stack trace to a backend so developers can discover bugs and issues their users are having.

Problem

Javascript error messages can be in the language that the browser is set to. It is not helpful for developers to see error messages written in languages we don’t know and it is more difficult to group related errors when the text does not match.

Example from Sentry:

Proposals

Here’s some ideas:

  • A way to set the error message language for the page, such as window.Error.lang='en'
  • A method on Error object instances to get the error message in the desired language, such as err.localizedMessage('en').

Existing Implementations

I am not aware of any browsers that have this feature at this time.

feeela
2015-01-15

This sounds to me like an artificial requirement.

Most programming languages are written in English and you can’t write JavaScript without knowing English. With your proposal, you would have the source code in English, but the some messages – directly related to that source code – may appear in a different language.

I know some cases were a software translates error messages (especially OS like Ubuntu or Windows) and I always get confused. Most technical articles on the web are written in English as well. When searching for a solution to some problem, I just can’t find a solution with the translated German error messages.

So I like my browsers UI to be in German, but JS errors should appear in English for ease of development.

toddhgardner
2015-01-16

Todd from TrackJS here. We have seen this quite a bit actually with international websites. To date, we solve the problem by translating the resulting error string, but this is a bit error prone. We would appreciate a way to set this in browser.

jonathank
2015-01-16

Even if there was an internal mapping to a set error code with the specific variables that go into the error message would be enough for me personally.

Like the following error:

 Uncaught ReferenceError: thing is not defined

Could have an additional unique param like errorCode or similar and errorParams:

try {
  shoe = thing;
} catch (err) {
    console.log(err.errorCode, err.errorParams);
    //12, ['thing']
}