unit dlang;

//
//  Minimalistic unit for getting and changing global language.
//

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

interface

type
PCountryInfo = ^TCountryInfo;
TCountryInfo = record
  Id: LongInt;
  TwoLetter: PAnsiChar;
  EnglishName: PAnsiChar;
  Name: PAnsiChar;
end;

PLangInfo = ^TLangInfo;
TLangInfo = record
  Id: LongInt;
  TwoLetter: PAnsiChar;
  ThreeLetter: PAnsiChar;
  EnglishName: PAnsiChar;
  Name: PAnsiChar;
end;

const
  LANG_ENGLISH_RECORD: TLangInfo = (
    Id: 0;
    TwoLetter: 'en';
    ThreeLetter: 'eng';
    EnglishName: 'English';
    Name: 'English';
    Country: (
      Id: 0;
      TwoLetter: 'US';
      EnglishName: 'USA';
      Name: 'USA';
    );
  );

  LANG_ENGLISH: PLangInfo = @LANG_ENGLISH_RECORD;

function Lang: PLangInfo; inline;
//
//      Returns current global language. English by default.
//

procedure ChangeLang(Lang: PLangInfo); overload; inline;
//
//      Changes current global language.
//

implementation

var
  CurrentLang: PLangInfo = @LANG_ENGLISH_RECORD;

function Lang: PLangInfo; inline;
begin
  Exit(CurrentLang);
end;

procedure ChangeLang(Lang: PLangInfo); inline;
begin
  if Lang = nil then
    Exit;
  CurrentLang := Lang;
end;

end.
