How to get localised day names in Delphi?


How to get localised day names in Delphi?



I'm using standard Delphi constants DayMonday, etc and I want to convert them to localized strings (eg "Lundi"). Is there a simple RTL or VCL call for this?




Wrapping TStringList in a Record

1:



Open source editors using (Uni)SynEdit [except Dev-PHP/Dev-C++]
You can get different locale settings by: .
How to create an array of controls?
var   fs : TFormatSettings;   x  : string; begin   GetLocaleFormatSettings(GetThreadlocale, fs);   x:= FormatDateTime('%mmmm', Now, fs);   // etc.. 


Are there any good free/cheap Delphi grid controls?
end;
GetThreadLocale gives the current LCID but you can use another number yourself..
Printing a TDBGrid
TFormatSettings record:.
GenoTechs GTSizer component [closed]
TFormatSettings = record   CurrencyFormat: Byte;   NegCurrFormat: Byte;   ThousandSeparator: Char;   DecimalSeparator: Char;   CurrencyDecimals: Byte;   DateSeparator: Char;   TimeSeparator: Char;   ListSeparator: Char;   CurrencyString: string;   ShortDateFormat: string;   LongDateFormat: string;   TimeAMString: string;   TimePMString: string;   ShortTimeFormat: string;   LongTimeFormat: string;   ShortMonthNames: array[1..12] of string;   LongMonthNames: array[1..12] of string;   ShortDayNames: array[1..7] of string;   LongDayNames: array[1..7] of string;   TwoDigitYearCenturyWindow: Word; end; 
See also http://www.microsoft.com/globaldev/reference/lcid-all.mspx for a complete list..
Cannot register multiple global hotkeys
You can even change the formatsettings yourself to create really fancy results..
ElevateDB relational model do’s and dont’s


2:


I thought I had found a simple way for the "current locale".

. There are global arrays LongDayNames[] and ShortDayNames[] defined in system.pas. So...
  Label.Text = LongDayName[DayMonday]; 
should work, for example.

Except it returns "Sunday".

This is because Delphi internally supports two day numbering schemes, and DayMonday is an the ISO8601 constant 1, while the LongDayName array expects sunday as the first day of the week.

C++Builder confuses things further because the string array then starts at zero, not one..



76 out of 100 based on 76 user ratings 976 reviews