How to make error message string localizations testable

I am working on an application that is currently localized in six languages. Localization engineers occasionally test to make sure that all of their strings are contextually appropriate and appear correctly in the application.

Something that's taking ever more time is their testing of error messages that are unlikely to be encountered with regular usage, or by following specific instructions. Originally, a developer would create the error conditions, cause the error to appear in each language, take screenshots, and send those to localization to inspect for correctness.

Someone noticed that this was taking a long time, and so built a helper-application in a development branch. This helper-application, when launched, shows a window beside the main application window with a list of error messages that can be shown. When the tester clicks on an entry in that list, reflection is used to burrow into the program logic and mess with private fields and such to create the error condition and cause the error message to appear. This does save time, but not all that much, because it's hard to maintain and extend.

I would like to find a better solution. Currently I'm considering refactoring the generation of all such error messages into a static class, and adding the "show error messages" window mentioned above to the application trunk, to appear only if a certain preprocessor symbol is defined. Then, error messages can be generated either in response to actual error conditions, or just in response to the click of a button in the "show error messages" window, with the same code generating the error message in both cases. The one significant thing that worries me is that we wouldn't be able to be totally sure that the same error message appears in both the real and fake error scenarios, though this is certainly also true of the reflection solution.

How have others dealt with similar situations?

This is a C# application with a WPF user interface.

• Can you indicate what platform you are using (.net, ios, etc.)? – Jon Raynor Aug 4 '16 at 17:05
• @Jon Added info, thanks. "This is a C# application with a WPF user interface." – Aurast Aug 4 '16 at 17:19

Try and create generic error messages:

"We're sorry, something bad happened."

Keep the number of error messages at a minimum. The details of the error message can be in the language of the development team and can be captured in a log file.

Even with validation messages, don't be specific. Use:

"Field is Required."

Then highlight the field on the form that failed validation.

Use instead of specific messages like "First Name is required." or similar. Use visual indicators or symbols instead of text. Basically, limit the use of text on error messages.

As far as testing, There's no simple way to test. You could write unit tests and set the local current culture to test each language:

CultureInfo cultureInof = new CultureInfo("fr-FR");