mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 22:14:25 +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;
|
Result:=DefaultFormatSettings;
|
||||||
end;
|
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;
|
procedure InitInternationalGeneric;
|
||||||
begin
|
begin
|
||||||
fillchar(SysLocale,sizeof(SysLocale),0);
|
fillchar(SysLocale,sizeof(SysLocale),0);
|
||||||
|
@ -31,6 +31,8 @@ type
|
|||||||
TMonthNameArray = array[1..12] of string;
|
TMonthNameArray = array[1..12] of string;
|
||||||
TWeekNameArray = array[1..7] of string;
|
TWeekNameArray = array[1..7] of string;
|
||||||
|
|
||||||
|
{ TFormatSettings }
|
||||||
|
|
||||||
TFormatSettings = record
|
TFormatSettings = record
|
||||||
CurrencyFormat: Byte;
|
CurrencyFormat: Byte;
|
||||||
NegCurrFormat: Byte;
|
NegCurrFormat: Byte;
|
||||||
@ -55,9 +57,11 @@ type
|
|||||||
class function Invariant : TFormatSettings; static;
|
class function Invariant : TFormatSettings; static;
|
||||||
class function Create: TFormatSettings; overload; static; inline;
|
class function Create: TFormatSettings; overload; static; inline;
|
||||||
// class function Create(Locale: TLocaleID): TFormatSettings; overload; platform; static;
|
// 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;
|
end;
|
||||||
|
|
||||||
|
TInitFormatSettingsHook = Procedure(const aLocale : string; var aSettings : TFormatSettings);
|
||||||
|
|
||||||
var
|
var
|
||||||
DefaultFormatSettings : TFormatSettings = (
|
DefaultFormatSettings : TFormatSettings = (
|
||||||
CurrencyFormat: 1;
|
CurrencyFormat: 1;
|
||||||
@ -84,7 +88,10 @@ var
|
|||||||
TwoDigitYearCenturyWindow: 50;
|
TwoDigitYearCenturyWindow: 50;
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
FormatSettings : TFormatSettings absolute DefaultFormatSettings;
|
FormatSettings : TFormatSettings absolute DefaultFormatSettings;
|
||||||
|
InitFormatSettingsHook : TInitFormatSettingsHook;
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
Date formatting settings
|
Date formatting settings
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
Loading…
Reference in New Issue
Block a user