RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.SysLocale Variable

SysLocale holds locale information.

Pascal
SysLocale: TSysLocale;
C++
TSysLocale SysLocale;

The SysLocale holds the attributes of the current locale. The locale determines how dates and times are formatted, how items are alphabetically sorted, and how strings are compared. 

The DefaultLCID field represents the locale identifier. This is a 32-bit value that specifies a default sort order and a default language identifier. 

The PirLangID field specifies the primary type of the language identifier. This is one of the constants that identify a language group, such as LANG_ENGLISH or LANG_FRENCH

The SubLangID field specifies the subtype of the language identifier. This is one of the constants that identify a language subgroup, such as SUBLANG_ENGLISH_US or SUBLANG_FRENCH_CANADIAN

FarEast is true or nonzero if User32.dll supports DBCS; false or zero otherwise. In other words, FarEast is true or nonzero if the double-byte character-set (DBCS) version of User.exe is installed; false or zero otherwise. 

MiddleEast is true if the system is enabled for Hebrew and Arabic languages; false otherwise.  

C++ Examples: 

 

/*
This example requires that a memo and a TApplicationEvent be
added to the form.  Change the Windows Locale by using the
Regional and Language Options in the Windows Control Panel.
*/
void __fastcall TForm1::ApplicationEvents1SettingChange(TObject *Sender, int Flag, const AnsiString Section, int &Result)
{
  Memo1->Lines->BeginUpdate();
  try
  {
//    char buffer[64];
    AnsiString buffer;
    buffer.sprintf("Section = %s", Section.c_str());
    Memo1->Lines->Add(buffer);
    buffer.sprintf("Flag = %8x", Flag);
    Memo1->Lines->Add(buffer);
    if (strcmp(Section.c_str(), "intl") == 0)
    {
      buffer.sprintf("DefaultLCID = %8x", SysLocale.DefaultLCID);
      Memo1->Lines->Add(buffer);
      buffer.sprintf("PriLangID = %8x", SysLocale.PriLangID);
      Memo1->Lines->Add(buffer);
      buffer.sprintf("SubLangID = %8x", SysLocale.SubLangID);
      Memo1->Lines->Add(buffer);
      buffer.sprintf("FarEast = %s", BoolToStr(SysLocale.FarEast, true));
      Memo1->Lines->Add(buffer);
      buffer.sprintf("MiddleEast = %s", BoolToStr(SysLocale.MiddleEast, true));
      Memo1->Lines->Add(buffer);
      Memo1->Lines->Add("");
    }
  }
  __finally
  {
    Memo1->Lines->EndUpdate();
  }
}

 

Delphi Examples: 

{
This example requires that a memo and a TApplicationEvent be
added to the form.  Change the Windows Locale by using the
Regional and Language Options in the Windows Control Panel.
}
procedure TForm1.ApplicationEvents1SettingChange(Sender: TObject; Flag: Integer; const Section: string; var Result: Integer);
begin
  Memo1.Lines.BeginUpdate;
  try
    Memo1.Lines.Add(Format('Section  = %s', [Section]));
    Memo1.Lines.Add(Format('Flags  = %.8x', [Flag]));
    if AnsiSameStr(Section, 'intl') then
    with SysLocale do
    begin
      Memo1.Lines.Add(Format('DefaultLCID  = %.8x', [DefaultLCID]));
      Memo1.Lines.Add(Format('PriLangID  = %.8x', [PriLangID]));
      Memo1.Lines.Add(Format('SubLangID  = %.8x', [SubLangID]));
      Memo1.Lines.Add(Format('FarEast  = %s', [BoolToStr(FarEast, True)]));
      Memo1.Lines.Add(Format('MiddleEast  = %s', [BoolToStr(MiddleEast, True)]));
    end;
    Memo1.Lines.Add('');
  finally
    Memo1.Lines.EndUpdate;
  end;
//  Result:= 0;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!