[Lazarus] OS X locale information (FormatSettings)
Craig Peterson
craig at scootersoftware.com
Mon Nov 14 18:41:50 CET 2011
A new OS X Carbon Lazarus project doesn't fill the FormatSettings
structure properly (using recent versions of Lazarus/FreePascal trunk).
It appears the FreePascal sanctioned method to support that is to add
clocale.pp to your project, but that only works when launched from the
terminal, not from the dock or directly from Lazarus.
I've attached the output from three variants below, to show the
differences. I first noticed the issue because by default Lazarus uses
'-' for the date separator, rather than '/', and adding clocale.pp
clears the ThousandSeparator value.
Is there a way to make clocale work correctly? If not, I think the
correct approach would be to replace it with a new unit that queries
CFLocaleGetValue instead.
The "LongDateFormat" string also doesn't match the system in any of the
approaches. According to my "Languages & Text" settings, it should be
something like "January 5, 2011" or "Jan 5, 2011".
On a related note, the AnsiString encoding isn't correct when launched
from the dock either. It should be UTF-8, but defaults to ASCII, so
extended characters are all converted to '?'. We've worked around the
issue by overriding LC_CTYPE in our .app .plist file, but it seems like
something that the environment should handle automatically.
Default Lazarus project (no clocale.pp)
CurrencyFormat: 1
NegCurrFormat: 5
ThousandSeparator: ,
DecimalSeparator: .
CurrencyDecimals: 2
DateSeparator: -
TimeSeparator: :
ListSeparator: ,
CurrencyString: $
ShortDateFormat: d/m/y
LongDateFormat: dd" "mmmm" "yyyy
TimeAMString: AM
TimePMString: PM
ShortTimeFormat: hh:nn
LongTimeFormat: hh:nn:ss
ShortMonthNames: Jan, Feb, ... Nov, Dec,
LongMonthNames: January, February, ... November, December,
ShortDayNames: Sun, Mon, Tue, Wed, Thu, Fri, Sat,
LongDayNames: Sunday, Monday, ... Friday, Saturday,
TwoDigitYearCenturyWindow: 50
clocale.pp, run from Terminal
CurrencyFormat: 0
NegCurrFormat: 1
ThousandSeparator: ,
DecimalSeparator: .
CurrencyDecimals: 2
DateSeparator: /
TimeSeparator: :
ListSeparator: ,
CurrencyString: $
ShortDateFormat: mm/dd/yyyy
LongDateFormat: mm/dd/yyyy
TimeAMString: AM
TimePMString: PM
ShortTimeFormat: hh:nn:ss
LongTimeFormat: hh:nn:ss ampm
ShortMonthNames: Jan, Feb, ... Nov, Dec,
LongMonthNames: January, February, ... November, December,
ShortDayNames: Sun, Mon, Tue, Wed, Thu, Fri, Sat,
LongDayNames: Sunday, Monday, ... Friday, Saturday,
TwoDigitYearCenturyWindow: 50
clocale.pp, run from Lazarus
CurrencyFormat: 1
NegCurrFormat: 5
ThousandSeparator:
DecimalSeparator: .
CurrencyDecimals: 127
DateSeparator: /
TimeSeparator: :
ListSeparator: ,
CurrencyString:
ShortDateFormat: mm/dd/yy
LongDateFormat: mm/dd/yy
TimeAMString: AM
TimePMString: PM
ShortTimeFormat: hh:nn:ss
LongTimeFormat: hh:nn:ss ampm
ShortMonthNames: Jan, Feb, ... Nov, Dec,
LongMonthNames: January, February, ... November, December,
ShortDayNames: Sun, Mon, Tue, Wed, Thu, Fri, Sat,
LongDayNames: Sunday, Monday, ... Friday, Saturday,
TwoDigitYearCenturyWindow: 50
--
Craig Peterson
Scooter Software
More information about the Lazarus
mailing list