Xel Naga
Xel Naga

Reputation: 956

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

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).

Upvotes: 4

Views: 662

Answers (1)

Peter
Peter

Reputation: 96

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

Upvotes: 8

Related Questions