Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent exception messages from being translated into the user's language?

How do I make my application always use English when displaying win32/.net exceptions messages?

I got this message, it looks like someone used babelfish to translate it (it's Swedish): "System.ComponentModel.Win32Exception: Programmet kunde inte starta eftersom programmets sida-vid-sidakonfiguration är felaktig."

Extremely unhelpful, and Google had a whopping 4 hits for it, none of them helpful. So I have to guess what the original message was and google that. (It's was: "The application has failed to start because its side-by-side configuration is incorrect.")

This time it was fairly simple to find out what the original error message was, having the message in English from the start would of course save me time.

So how do I do that?

like image 261
Nifle Avatar asked Oct 13 '08 09:10

Nifle


People also ask

Should error messages be translated?

Depends on the app. A highly technical application that will be used by people that understand English and the target language, you might be OK with English error messages. If it's a message that will be seen by the end user, it should be translated.

How do I write an exception message?

Use grammatically correct error messagesWrite clear sentences and include ending punctuation. Each sentence in the string assigned to the Exception. Message property should end in a period. For example, "The log table has overflowed." would be an appropriate message string.


1 Answers

You can try setting Thread.CurrentThread.CurrentUICulture and/or .CurrentCulture to CultureInfo("en-US").

like image 162
Alexander Kojevnikov Avatar answered Oct 13 '22 18:10

Alexander Kojevnikov