Tuesday 25 June 2013

All Your Errors, Now In English

Internet Explorer has this interesting behavior that all its errors are localized to the user's preferred language. I'm not sure if that's a good thing, since English is effectively the lingua-franca of programming, and there are so few programming languages that don't use English keywords. Ah, well. One could argue, that if the user has set their browser locale to a non-English language, the browser should display errors in the user's preferred language. After all, the error message is seen by the user.

However, with Errorception, errors are taken out from the browser and saved on a server for an entirely different audience to see. The fact that the language isn't English causes all sorts of problems. Since the languages are different, it's hard to tell at a glance if two errors are duplicates of each other. As you will have multiple error entries created because of this, it leads to other problems. For example, you can't prioritize correctly, since the number of errors are more than they should be, and number of individual occurrences of these errors are less than they should be. It's such a mess!

I'm proud to announce that this problem has now been cracked in the most comprehensive and cleanest way possible. With a lot of help from Rajasekharan Vengalil, Developer Evangelist at Microsoft, we managed to extract the language resource bundles from Internet Explorer's binaries for 35(!) different languages. (By "with a lot of help", I mean "he did all the work".) Once I had the language files, I could then create a mapping between errors in different languages.

Now, when an error comes to Errorception, the code walks across the language mapping, figures out the language of the error and its corresponding English version, finds the tokens (variable names, generally) in the error message, puts these tokens into the appropriate places in the English version of the error, and thus reconstructs the English version of the error. For completeness, the original error is also stored along with your raw logs.

So, starting some time ago, you will now receive all your errors in English, even if the errors are in browsers with a different language! This also means that the right error messages from IE are grouped together correctly, irrespective of the users' settings! And this works across 35 languages for hundreds of errors – even the latest bunch of errors thrown with the new ES5 support in IE!

Oh, and don't forget to buy Raj a beer when you meet him. :)