unit ant_localizer_windows;

{$MODE FPC}
{$MODESWITCH DEFAULTPARAMETERS}
{$MODESWITCH OUT}
{$MODESWITCH RESULT}

interface

function GetLang_Windows: AnsiString;
      //  Returns 2-letter language identifier (i.e. ISO 639-1) of current user
      //  language.

implementation

uses
  windows;

function GetLang_Windows: AnsiString;
var
  Id: windows.LCID;
begin
  Id := GetUserDefaultLCID();
  SetLength(Result, 6);
  if  (GetLocaleInfoA(Id, LOCALE_SISO639LANGNAME,  @Result[1], 3) = 3)
  and (GetLocaleInfoA(Id, LOCALE_SISO3166CTRYNAME, @Result[4], 3) = 3) then begin
    Result[3] := '_';
  end else
    Result := 'en_US'; // something went wrong...
end;

end.
