Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 883
Xel Naga Avatar asked Mar 02 '23 09:03

Xel Naga


1 Answers

function GetUsersWindowsLanguage: string;
var
  WinLanguage: array [0..50] of char;
begin
  GetLocaleInfoW(GetUserDefaultUILanguage, LOCALE_SENGLISHDISPLAYNAME, WinLanguage, 50);
  Result := WinLanguage;
end;
like image 192
Peter Avatar answered Mar 18 '23 17:03

Peter