Display language of current user (in English) using Delphi?

Viewed 286

Some Windows computers have multiple display languages installed.

I can get the current user's UI language in that language using the function:

function GetUsersWindowsLanguage: string;
var
  WinLanguage: array [0..50] of char;
begin
  VerLanguageName(GetUserDefaultUILanguage, WinLanguage, 50);
  Result := WinLanguage;
end;

This function outputs something like this:

Espagnol (Espagne)

The output is not in English. All I need is "Spanish". Is there any way to get the display language in English?

I'm using Delphi 10.3.3 (VCL application).

1 Answers
function GetUsersWindowsLanguage: string;
var
  WinLanguage: array [0..50] of char;
begin
  GetLocaleInfoW(GetUserDefaultUILanguage, LOCALE_SENGLISHDISPLAYNAME, WinLanguage, 50);
  Result := WinLanguage;
end;
Related