Event log messages - what a bother!
A localizer such as myself, working on a large project such as Windows, is bound to come across strings used for a kinds of purposes. One of the keys to delivering a good quality localized product is to figure out how the various strings are actually used at run time. This is very much a guessing game. You're given random clues, hopefully there are enough clues for you to make a good prediction. If not, quality suffers. That's why I've been writing these posts over the last couple of weeks - how to identify and treat different kinds of strings when you localize. Today it's time for the latest installment - event log messages.
Similar to performance counters, there's a set of base event log messages in msaudite.dll and applications can and do include their own event log messages. Since different files are owned by different developers, they will have some different characteristics. Still, there are some things you can look for.
Here's a fairly typical example of a message:
Handle Closed:%n\r\n%tObject Server:%t%1%n\r\n%tHandle ID:%t%2%n\r\n%tProcess ID:%t%3%n\r\n%tImage File Name:%t%4%n\r\n
This string 1) starts with an informative status message; it 2) contains a lot of data that provides context about the event, and 3) contains a mix of \r\n, %t and %n for formatting. Ten strings out of nine that look like this are event log messages. Other event log messages might not contain all of these clues, but with some experience you'll know one when you see it.
There are a few things you want to keep in mind when localizing event log messages, like:
- Just like dos syntax messages, you probably want to keep them nicely formatted.
- Unlike dos syntax messages, which are shown in a fixed-width font, these ones are displayed in the Event Viewer in the normal font. This is important because the width of characters and tabs is harder to predict now.
- Every "normal" line feed (\r\n) will be shown as one single space in the Event viewer. %n will be the line feed, and %t will be a tab. From this follows that you're free to add and remove %n and %t as you need in order to format the message.
- You have limited width in the event viewer UI. You might therefore need to add more %n's.
To handle this, I employ two strategies. First, I use a home-built second editor for localizing the strings. This editor gives me a fair preview of what a string will look like in run time. Here's an example of a flat string:
%tUser Name:%t%1%n\r\n%tDomain:%t%%t%2%n\r\n%tRequest Type:%t%3%n\r\n%tLogon Process:%t%4%n\r\n%tAuthentication Package:%t%5%n\r\n%tWorkstation Name:%t%6%n\r\n%tCaller User Name:%t%7%n\r\n%tCaller Domain:%t%8%n\r\n%tCaller Logon ID:%t%9%n\r\n%tCaller Process ID: %10%n\r\n%tTransited Services: %11%n\r\n
%tAnvändarnamn:%t%t%1%n\r\n%tDomän:%t%t%t%2%n\r\n%tBegärandetyp:%t%t%3%n\r\n%tInloggningsprocess:%t%t%4%n\r\n%tAutentiseringspaket:%t%5%n\r\n%tArbetsstationens namn:%t%6%n\r\n%tAnroparens användarnamn:%t%7%n\r\n%tAnroparens domän:%t%t%8%n\r\n%tAnroparens inloggnings-ID:%t%9%n\r\n%tAnroparens process-ID: %t%10%n\r\n%tÖverförda tjänster: %t%t%11%n\r\n
And here's what I preview:
To get even better preview, I also added a feature that lets me write a message I localize to the event log. This is dead easy to do, MSDN contains all the information you need. Since the preview above is rather artificial and since you can't expect to have test cases that cause each and every possible message to be written to the log at runtime, I find it useful to dump in a whole lot of them at once and have a quick scan through the event viewer.
If you do a good job, your messages will be nicely aligned and your customers will love you endlessly. Just look at how gorgeous it can be:
This posting is provided "AS IS" with no warranties, and confers no rights.