localization both ways

The localization of messages on Windows is done through the MUI files. I.e. aside from mycmd.exe or mylib.dll you get the strings file mycmd.exe.mui or mylib.dll.mui, to be placed next to it in a subdirectory named per the language, like “en-us”, and the system will let you open and get the strings according to the user’s current language (such as in this example).

But first you’ve got to define the strings. There are two ways to do it:

  • The older way, in a message file with the extension .mc.
  • The newer way, in an XML manifest with the extension .man.

The .mc files are much more convenient. The .man files are much more verbose and painful, requiring more of the manual maintenance. But the manifest files are also more flexible, defining not only the strings but also the ETW messages (that might also use some of these strings). So if you want to sent the manifested ETW messages (as of Windows 10 there also are the un-manifested ETW messages, or more exactly, the self-manifesting messages), you’ve got to use the manifest file to define them.

But there is only one string section per binary. You can’t have multiple separate message files and manifest files, compile them separate and then merge. You can compile and put them in but only the first section will be used. Which pretty much means that you can’t use the localized strings or ETW messages in a static library: when you link the static library into a binary, you won’t be able to include its strings. If you want localization or ETW, you’ve got to make each your library into a DLL. Or have some workaround way to merge the strings from all the static libraries you use into one before compiling it.

However there is one special exception that is not too widely known: the message compiler mc.exe can accept exactly one .mc file and exactly one .man file, and combine them into a single compiled strings section. So you can define the ETW messages and strings for them in a .man file in the more painful way, and the rest of the strings in the .mc file in the less painful way, and it will still work. Just make sure that you have no overlaps in the message IDs. I’m not sure why can’t they read multiple files of each type and put them all together. But at least you won’t have to convert the .mc files to .man.

Comments (0)

Skip to main content