FormatMessage to a different language

1.5k Views Asked by At

Is it possible to translate system error codes to a specific language?

I can only pass MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) to FormatMessage. Otherwise, function call fails with 15100 (The resource loader failed to find MUI file).

Where are system error messages stored? Why can't I load a message in a locale different from the system one?

2

There are 2 best solutions below

0
On BEST ANSWER

Basically MUI stands for multilingual user interface. These are language packs. In windows one won't get them by default. Instead they have to install

Below link helps you regarding procurement.

https://support.microsoft.com/en-us/help/14236/language-packs

By default the above page displays for windows 10 . there is a drop down option to select for the other versions of windows.

If you have difficulty with above link, search in google for MUI language pack for windows 10 or any other version.

0
On

Use zero for language id, not MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US). Then FormatMessage will pick the resource based on thread's language id, or it uses GetUserDefaultLangID.

FormatMessage documentation:

DWORD WINAPI FormatMessage(
  _In_     DWORD   dwFlags,
  _In_opt_ LPCVOID lpSource,
  _In_     DWORD   dwMessageId,
  _In_     DWORD   dwLanguageId,
  _Out_    LPTSTR  lpBuffer,
  _In_     DWORD   nSize,
  _In_opt_ va_list *Arguments
);

dwLanguageId:

If you pass a specific LANGID in this parameter, FormatMessage will return a message for that LANGID only. If the function cannot find a message for that LANGID, it sets Last-Error to ERROR_RESOURCE_LANG_NOT_FOUND. If you pass in zero, FormatMessage looks for a message for LANGIDs in the following order:

  1. Language neutral
  2. Thread LANGID, based on the thread's locale value
  3. User default LANGID, based on the user's default locale value
  4. System default LANGID, based on the system default locale value
  5. US English