mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 00:08:12 +02:00
* Allow TFormatSettings.Create with string (using callback)
This commit is contained in:
parent
e062a54716
commit
35a21de57c
@ -54,6 +54,17 @@ begin
|
||||
Result:=DefaultFormatSettings;
|
||||
end;
|
||||
|
||||
class function TFormatSettings.Create(const LocaleName: string): TFormatSettings;
|
||||
begin
|
||||
// Catch
|
||||
if LocaleName.StartsWith('en-US') then
|
||||
Result:=TFormatSettings.Invariant
|
||||
else if assigned(InitFormatSettingsHook) then
|
||||
InitFormatSettingsHook(LocaleName,Result)
|
||||
else
|
||||
Raise ENotSupportedException.Create('No support for transforming locale name to format settings')
|
||||
end;
|
||||
|
||||
procedure InitInternationalGeneric;
|
||||
begin
|
||||
fillchar(SysLocale,sizeof(SysLocale),0);
|
||||
|
@ -31,6 +31,8 @@ type
|
||||
TMonthNameArray = array[1..12] of string;
|
||||
TWeekNameArray = array[1..7] of string;
|
||||
|
||||
{ TFormatSettings }
|
||||
|
||||
TFormatSettings = record
|
||||
CurrencyFormat: Byte;
|
||||
NegCurrFormat: Byte;
|
||||
@ -55,9 +57,11 @@ type
|
||||
class function Invariant : TFormatSettings; static;
|
||||
class function Create: TFormatSettings; overload; static; inline;
|
||||
// class function Create(Locale: TLocaleID): TFormatSettings; overload; platform; static;
|
||||
// class function Create(const LocaleName: string): TFormatSettings; overload; static;
|
||||
class function Create(const LocaleName: string): TFormatSettings; overload; static;
|
||||
end;
|
||||
|
||||
TInitFormatSettingsHook = Procedure(const aLocale : string; var aSettings : TFormatSettings);
|
||||
|
||||
var
|
||||
DefaultFormatSettings : TFormatSettings = (
|
||||
CurrencyFormat: 1;
|
||||
@ -84,7 +88,10 @@ var
|
||||
TwoDigitYearCenturyWindow: 50;
|
||||
);
|
||||
|
||||
|
||||
FormatSettings : TFormatSettings absolute DefaultFormatSettings;
|
||||
InitFormatSettingsHook : TInitFormatSettingsHook;
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Date formatting settings
|
||||
---------------------------------------------------------------------}
|
||||
|
Loading…
Reference in New Issue
Block a user