You've already forked lina-components
mirror of
https://bitbucket.org/Dennis07/lina-components.git
synced 2025-08-24 21:49:04 +02:00
Version 1.0 DEV 1.13a
Signed-off-by: Dennis07 <den.goehlert@t-online.de>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
; No-section content
|
||||
HelloWorld = Hallo Welt! ; MessageBox variable
|
||||
HelloWorld = Hallo, $# 10 Welt! ; MessageBox variable
|
||||
Language = Sprache
|
||||
LanguageSelect @ LANGUAGE
|
||||
* Buttons
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -58,7 +58,7 @@ var
|
||||
Index: Integer;
|
||||
LanguageFiles: TStrings;
|
||||
begin
|
||||
HelloWorld := 'Hello, World!';
|
||||
HelloWorld := 'Hello,' + #10 + 'World!';
|
||||
(LocalizationManager.References.Items[0] as TLocalizationReference).Reference := @HelloWorld;
|
||||
LanguageFiles := TStringList.Create;
|
||||
ListFiles(ExtractFileDir(Application.ExeName),LanguageFiles,['*.loc']);
|
||||
@@ -66,8 +66,9 @@ begin
|
||||
for Index := 0 to LanguageFiles.Count - 1 do
|
||||
begin
|
||||
(LocalizationManager.Localizations.Add as TLocalization).Lines.LoadFromFile(ExtractFilePath(Application.ExeName) + ChangeFileExt(LanguageFiles.Strings[Index],'.loc'));
|
||||
//(LocalizationManager.Localizations.Items[Index] as TLocalization).Format.Indent := '+';
|
||||
// (LocalizationManager.Localizations.Items[Index] as TLocalization).Format.Indent := '+';
|
||||
end;
|
||||
//LocalizationManager.Applier.ApplyMode := laMainForm;
|
||||
end;
|
||||
|
||||
procedure TForm1.lbLanguageClick(Sender: TObject);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
These statistics cover the official repository of Lina Components.
|
||||
|
||||
Total lines of code (LoC): 8100+
|
||||
Total lines of code (LoC): 8300+
|
||||
Total visual components (VC): 15
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -22,7 +22,7 @@ uses
|
||||
|
||||
const
|
||||
Package_Name = 'Lina Components';
|
||||
Package_Description = 'Components and code library for Delphi' + sLineBreak + '� 2014 Dennis G�hlert a.o.';
|
||||
Package_Description = 'Components and code library for Delphi' + sLineBreak + '� 2015 Dennis G�hlert a.o.';
|
||||
Package_License = 'Mozilla Public License (MPL) 2.0';
|
||||
Package_SKU = '(Dev-Preview)';
|
||||
|
||||
|
@@ -32,6 +32,7 @@ type
|
||||
{ Hilfsklassen }
|
||||
TLanguageTag = String[3];
|
||||
TCommentAllow = type TLinePosition;
|
||||
TLocalizationApplyMode = (laCustom,laAll,laMainForm,laNone);
|
||||
|
||||
type
|
||||
{ Ereignisse }
|
||||
@@ -47,17 +48,19 @@ type
|
||||
private
|
||||
{ Private-Deklarationen }
|
||||
FAllowComment: TCommentAllow;
|
||||
FComment: ShortString;
|
||||
FSeparator: ShortString;
|
||||
FHeader: ShortString;
|
||||
FIndent: ShortString;
|
||||
FAddress: ShortString;
|
||||
FComment: String;
|
||||
FSeparator: String;
|
||||
FHeader: String;
|
||||
FIndent: String;
|
||||
FAddress: String;
|
||||
FCharacter: String;
|
||||
{ Methoden }
|
||||
procedure SetComment(Value: ShortString);
|
||||
procedure SetSeparator(Value: ShortString);
|
||||
procedure SetHeader(Value: ShortString);
|
||||
procedure SetIndent(Value: ShortString);
|
||||
procedure SetAddress(Value: ShortString);
|
||||
procedure SetComment(Value: String);
|
||||
procedure SetSeparator(Value: String);
|
||||
procedure SetHeader(Value: String);
|
||||
procedure SetIndent(Value: String);
|
||||
procedure SetAddress(Value: String);
|
||||
procedure SetCharacter(Value: String);
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create;
|
||||
@@ -65,11 +68,12 @@ type
|
||||
published
|
||||
{ Published-Deklarationen }
|
||||
property AllowComment: TCommentAllow read FAllowComment write FAllowComment default lpAnyPosition;
|
||||
property Comment: ShortString read FComment write SetComment; //nicht leer
|
||||
property Separator: ShortString read FSeparator write SetSeparator; //nicht leer
|
||||
property Header: ShortString read FHeader write SetHeader;
|
||||
property Indent: ShortString read FIndent write SetIndent;
|
||||
property Address: ShortString read FAddress write SetAddress;
|
||||
property Comment: String read FComment write SetComment; //nicht leer
|
||||
property Separator: String read FSeparator write SetSeparator; //nicht leer
|
||||
property Header: String read FHeader write SetHeader;
|
||||
property Indent: String read FIndent write SetIndent;
|
||||
property Address: String read FAddress write SetAddress;
|
||||
property Character: String read FCharacter write SetCharacter;
|
||||
end;
|
||||
|
||||
TLocalization = class(TCollectionItem)
|
||||
@@ -174,12 +178,11 @@ type
|
||||
{ Methoden }
|
||||
procedure SetIndent(Value: String);
|
||||
procedure SetComponent(Value: TComponent);
|
||||
procedure Apply;
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
destructor Destroy; override;
|
||||
property Reference: PString read FReference write FReference;
|
||||
{ Methoden }
|
||||
procedure Apply;
|
||||
published
|
||||
{ Published-Deklarationen }
|
||||
property Section: String read FSection write FSection;
|
||||
@@ -187,6 +190,29 @@ type
|
||||
property Component: TComponent read FComponent write SetComponent;
|
||||
end;
|
||||
|
||||
TLocalizationApplier = class
|
||||
private
|
||||
{ Private-Deklarationen }
|
||||
FManager: TLocalizationManager;
|
||||
FApplyMode: TLocalizationApplyMode;
|
||||
{ Methoden }
|
||||
procedure SetApplyMode(Value: TLocalizationApplyMode);
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create(AManager: TLocalizationManager);
|
||||
destructor Destroy; override;
|
||||
{ Methoden }
|
||||
procedure Apply;
|
||||
protected
|
||||
{ Protected-Deklarationen }
|
||||
procedure ApplyToComponent(Component: TComponent; Section,Indent: String);
|
||||
procedure ApplyToForm(Form: TCustomForm);
|
||||
procedure ApplyToAll;
|
||||
published
|
||||
{ Published-Deklarationen }
|
||||
property ApplyMode: TLocalizationApplyMode read FApplyMode write SetApplyMode default laCustom;
|
||||
end;
|
||||
|
||||
TLocalizationManager = class(TComponent)
|
||||
private
|
||||
{ Ereignisse}
|
||||
@@ -201,15 +227,15 @@ type
|
||||
FReferences: TLocalizationReferences;
|
||||
FCurrent: Integer;
|
||||
FIgnoreCase: Boolean;
|
||||
FApplier: TLocalizationApplier;
|
||||
{ Methoden }
|
||||
procedure SetCurrent(Value: Integer);
|
||||
procedure SetIgnoreCase(Value: Boolean);
|
||||
protected
|
||||
{ Protected-Deklarationen }
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create(AOwnder: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
{ Eigenschaften }
|
||||
property Data: TLocalizationData read FData write FData;
|
||||
published
|
||||
{ Published-Deklarationen }
|
||||
@@ -224,6 +250,7 @@ type
|
||||
property References: TLocalizationReferences read FReferences write FReferences;
|
||||
property Current: Integer read FCurrent write SetCurrent default -1;
|
||||
property IgnoreCase: Boolean read FIgnoreCase write SetIgnoreCase default True;
|
||||
property Applier: TLocalizationApplier read FApplier write FApplier;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
@@ -254,6 +281,7 @@ begin
|
||||
FSeparator := '=';
|
||||
FHeader := '*';
|
||||
FAddress := '@';
|
||||
FCharacter := '$#';
|
||||
end;
|
||||
|
||||
destructor TLocalizationFormat.Destroy;
|
||||
@@ -262,11 +290,11 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TLocalizationFormat.SetComment(Value: ShortString);
|
||||
procedure TLocalizationFormat.SetComment(Value: String);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if (ArrayPos(Value,[FSeparator,FHeader,FIndent,FAddress]) <> -1) or (Length(Value) = 0) then
|
||||
if (ArrayPos(Value,[FSeparator,FHeader,FIndent,FAddress,FCharacter]) <> -1) or (Length(Value) = 0) then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Comment"');
|
||||
end;
|
||||
@@ -280,11 +308,11 @@ begin
|
||||
FComment := Value;
|
||||
end;
|
||||
|
||||
procedure TLocalizationFormat.SetSeparator(Value: ShortString);
|
||||
procedure TLocalizationFormat.SetSeparator(Value: String);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if (ArrayPos(Value,[FComment,FHeader,FIndent,FAddress]) <> -1) or (Length(Value) = 0) then
|
||||
if (ArrayPos(Value,[FComment,FHeader,FIndent,FAddress,FCharacter]) <> -1) or (Length(Value) = 0) then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Separator"');
|
||||
end;
|
||||
@@ -298,11 +326,11 @@ begin
|
||||
FSeparator := Value;
|
||||
end;
|
||||
|
||||
procedure TLocalizationFormat.SetHeader(Value: ShortString);
|
||||
procedure TLocalizationFormat.SetHeader(Value: String);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if ArrayPos(Value,[FComment,FSeparator,FIndent,FAddress]) <> -1 then
|
||||
if ArrayPos(Value,[FComment,FSeparator,FIndent,FAddress,FCharacter]) <> -1 then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Header"');
|
||||
end;
|
||||
@@ -316,11 +344,11 @@ begin
|
||||
FHeader := Value;
|
||||
end;
|
||||
|
||||
procedure TLocalizationFormat.SetIndent(Value: ShortString);
|
||||
procedure TLocalizationFormat.SetIndent(Value: String);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if ArrayPos(Value,[FComment,FSeparator,FHeader,FAddress]) <> -1 then
|
||||
if ArrayPos(Value,[FComment,FSeparator,FHeader,FAddress,FCharacter]) <> -1 then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Indent"');
|
||||
end;
|
||||
@@ -334,11 +362,11 @@ begin
|
||||
FIndent := Value;
|
||||
end;
|
||||
|
||||
procedure TLocalizationFormat.SetAddress(Value: ShortString);
|
||||
procedure TLocalizationFormat.SetAddress(Value: String);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if (ArrayPos(Value,[FComment,FSeparator,FHeader,FIndent]) <> -1) or (Length(Value) = 0) then
|
||||
if (ArrayPos(Value,[FComment,FSeparator,FHeader,FIndent,FCharacter]) <> -1) or (Length(Value) = 0) then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Address"');
|
||||
end;
|
||||
@@ -352,6 +380,24 @@ begin
|
||||
FAddress := Value;
|
||||
end;
|
||||
|
||||
procedure TLocalizationFormat.SetCharacter(Value: String);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if (ArrayPos(Value,[FComment,FSeparator,FHeader,FIndent,FAddress]) <> -1) or (Length(Value) = 0) then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Character"');
|
||||
end;
|
||||
for Index := 1 to Length(Value) do
|
||||
begin
|
||||
if Value[Index] in Spaces then
|
||||
begin
|
||||
raise EInvalidFormat.Create('Invalid localization format for property: "Character"');
|
||||
end;
|
||||
end;
|
||||
FCharacter := Value;
|
||||
end;
|
||||
|
||||
{ ----------------------------------------------------------------------------
|
||||
TLocalization
|
||||
---------------------------------------------------------------------------- }
|
||||
@@ -464,17 +510,21 @@ var
|
||||
Finished: Boolean;
|
||||
Header: Boolean;
|
||||
Address: Boolean;
|
||||
Character: Boolean;
|
||||
Current: PChar;
|
||||
InComment: PChar;
|
||||
InCharacter: PChar;
|
||||
Block: String;
|
||||
Section: String;
|
||||
Indent: String;
|
||||
Ordinal: String;
|
||||
label
|
||||
EoL;
|
||||
begin
|
||||
Result := False;
|
||||
Section := '';
|
||||
Indent := '';
|
||||
Ordinal := '';
|
||||
for Line := 0 to Lines.Count - 1 do
|
||||
begin
|
||||
//Leere Zeile
|
||||
@@ -488,16 +538,26 @@ begin
|
||||
Address := False;
|
||||
Complete := False;
|
||||
Finished := False;
|
||||
Character := False;
|
||||
Current := @Lines.Strings[Line][1];
|
||||
InComment := @Format.Comment[1];
|
||||
InCharacter := @Format.Character[1];
|
||||
//Parsen
|
||||
while Complete = False do
|
||||
begin
|
||||
if (not (Current^ in Spaces)) or ((((Address = False) and (Position = posValue)) or (Header = True)) and (Length(Block) <> 0)) then
|
||||
if ((Address = False) or (Current^ <> #0)) and (not (Current^ in Spaces)) or ((((Address = False) and (Position = posValue)) or (Header = True)) and (Length(Block) <> 0)) then
|
||||
begin
|
||||
//Zeichen zu Block hinzuf�gen
|
||||
Block := Block + Current^;
|
||||
if Current = @Lines.Strings[Line][Length(Lines.Strings[Line])] then
|
||||
if Character = False then
|
||||
begin
|
||||
Block := Block + Current^;
|
||||
if address = true then
|
||||
address := true;
|
||||
end else
|
||||
begin
|
||||
Ordinal := Ordinal + Current^;
|
||||
end;
|
||||
if (Current^ = #0{@Lines.Strings[Line][Length(Lines.Strings[Line])]}) or ((Character = True) and (Current^ in Spaces)) then
|
||||
begin
|
||||
goto EoL;
|
||||
end else
|
||||
@@ -520,17 +580,53 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
//Character-Unterst�tzung in Value
|
||||
if Position = posValue then
|
||||
begin
|
||||
if InCharacter^ = Current^ then
|
||||
begin
|
||||
Inc(InCharacter);
|
||||
end else
|
||||
begin
|
||||
if (InCharacter^ = #0) and (Current^ in Spaces) then
|
||||
begin
|
||||
Character := True;
|
||||
SetLength(Block,Length(Block) - Length(Format.Character) - 1);
|
||||
end else
|
||||
begin
|
||||
InCharacter := @Format.Character[1];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
//Alternativ auch bei Zeilenende
|
||||
EoL:
|
||||
if Length(Ordinal) <> 0 then
|
||||
begin
|
||||
if Length(Block) <> 0 then
|
||||
begin
|
||||
SetLength(Block,Length(Block) - 1);
|
||||
Insert(Chr(StrToInt(Trim(Ordinal))),Block,Length(Block) + 1);
|
||||
end else
|
||||
begin
|
||||
Block := Chr(StrToInt(Trim(Ordinal)));
|
||||
end;
|
||||
Ordinal := '';
|
||||
Character := False;
|
||||
if Current^ <> #0 then
|
||||
begin
|
||||
Inc(Current);
|
||||
Continue;
|
||||
end;
|
||||
end;
|
||||
if (Length(Block) <> 0) or ((Position = posValue) and (Address = False)) or ((Position = posIndent) and (Header = True)) then
|
||||
begin
|
||||
if //Kommentaranfang
|
||||
((Block = Format.Comment) and ((Format.AllowComment = lpAnyPosition) or ((Format.AllowComment = lpBeginning) and (Current = @Lines.Strings[Line][1]))) or (Current = @Lines.Strings[Line][Length(Lines.Strings[Line])]) or (InComment^ = #0)) or
|
||||
((Block = Format.Comment) and ((Format.AllowComment = lpAnyPosition) or ((Format.AllowComment = lpBeginning) and (Current = @Lines.Strings[Line][1]))) or (Current^ = #0{@Lines.Strings[Line][Length(Lines.Strings[Line])]}) or (InComment^ = #0)) or
|
||||
//Zeilenende
|
||||
((Current = @Lines.Strings[Line][Length(Lines.Strings[Line])]) and (not (Current^ in Spaces))) or
|
||||
((Current^ = #0{@Lines.Strings[Line][Length(Lines.Strings[Line])]}) and (not (Current^ in Spaces))) or
|
||||
//Adressenende
|
||||
(Address = True) then
|
||||
begin
|
||||
@@ -557,7 +653,7 @@ begin
|
||||
end else
|
||||
begin
|
||||
//Adressierung
|
||||
Complete := (Current = @Lines.Strings[Line][Length(Lines.Strings[Line])]);
|
||||
Complete := (Current^ = #0{@Lines.Strings[Line][Length(Lines.Strings[Line])]});
|
||||
if (Collection as TLocalizations).FManager.Data.IndentExists(Section,Block) = True then
|
||||
begin
|
||||
(Collection as TLocalizations).FManager.Data.Address(Section,Indent,Block);
|
||||
@@ -902,121 +998,203 @@ begin
|
||||
begin
|
||||
Reference^ := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,Reference^);
|
||||
end;
|
||||
(Collection as TLocalizationReferences).FManager.Applier.ApplyToComponent(Component,Section,Indent);
|
||||
end;
|
||||
|
||||
{ ----------------------------------------------------------------------------
|
||||
TLocalizationApplier
|
||||
---------------------------------------------------------------------------- }
|
||||
|
||||
constructor TLocalizationApplier.Create(AManager: TLocalizationManager);
|
||||
begin
|
||||
inherited Create;
|
||||
FManager := AManager;
|
||||
FApplyMode := laCustom;
|
||||
end;
|
||||
|
||||
destructor TLocalizationApplier.Destroy;
|
||||
begin
|
||||
FManager := nil;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TLocalizationApplier.SetApplyMode(Value: TLocalizationApplyMode);
|
||||
begin
|
||||
FApplyMode := Value;
|
||||
Apply;
|
||||
end;
|
||||
|
||||
procedure TLocalizationApplier.Apply;
|
||||
begin
|
||||
case FApplyMode of
|
||||
laCustom: FManager.References.Apply;
|
||||
laAll: ApplyToAll;
|
||||
laMainForm: ApplyToForm(Application.MainForm);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLocalizationApplier.ApplyToComponent(Component: TComponent; Section,Indent: String);
|
||||
begin
|
||||
if Assigned(Component) = True then
|
||||
begin
|
||||
//TForm
|
||||
if Component is TForm then
|
||||
begin
|
||||
(Component as TForm).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TForm).Caption);
|
||||
(Component as TForm).Caption := FManager.Data.ReadString(Section,Indent,(Component as TForm).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TButton
|
||||
if Component is TButton then
|
||||
begin
|
||||
(Component as TButton).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TButton).Caption);
|
||||
(Component as TButton).Caption := FManager.Data.ReadString(Section,Indent,(Component as TButton).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TEdit
|
||||
if Component is TEdit then
|
||||
begin
|
||||
(Component as TEdit).Text := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TEdit).Text);
|
||||
(Component as TEdit).Text := FManager.Data.ReadString(Section,Indent,(Component as TEdit).Text);
|
||||
Exit;
|
||||
end;
|
||||
//TLabeledEdit
|
||||
if Component is TLabeledEdit then
|
||||
begin
|
||||
(Component as TLabeledEdit).Text := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TLabeledEdit).Text);
|
||||
(Component as TLabeledEdit).Text := FManager.Data.ReadString(Section,Indent,(Component as TLabeledEdit).Text);
|
||||
Exit;
|
||||
end;
|
||||
//TBoundLabel
|
||||
if Component is TBoundLabel then
|
||||
begin
|
||||
(Component as TBoundLabel).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TBoundLabel).Caption);
|
||||
(Component as TBoundLabel).Caption := FManager.Data.ReadString(Section,Indent,(Component as TBoundLabel).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TCheckBox
|
||||
if Component is TCheckBox then
|
||||
begin
|
||||
(Component as TCheckBox).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TCheckBox).Caption);
|
||||
(Component as TCheckBox).Caption := FManager.Data.ReadString(Section,Indent,(Component as TCheckBox).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TComboBox
|
||||
if Component is TComboBox then
|
||||
begin
|
||||
(Component as TComboBox).Text := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TComboBox).Text);
|
||||
(Component as TComboBox).Text := FManager.Data.ReadString(Section,Indent,(Component as TComboBox).Text);
|
||||
Exit;
|
||||
end;
|
||||
//TMemo
|
||||
if Component is TMemo then
|
||||
begin
|
||||
(Component as TMemo).Text := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TMemo).Text);
|
||||
(Component as TMemo).Text := FManager.Data.ReadString(Section,Indent,(Component as TMemo).Text);
|
||||
Exit;
|
||||
end;
|
||||
//TListBox
|
||||
if Component is TListBox then
|
||||
begin
|
||||
(Component as TListBox).Items.Text := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TListBox).Items.Text);
|
||||
(Component as TListBox).Items.Text := FManager.Data.ReadString(Section,Indent,(Component as TListBox).Items.Text);
|
||||
Exit;
|
||||
end;
|
||||
//TLabel
|
||||
if Component is TLabel then
|
||||
begin
|
||||
(Component as TLabel).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TLabel).Caption);
|
||||
(Component as TLabel).Caption := FManager.Data.ReadString(Section,Indent,(Component as TLabel).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TStaticText
|
||||
if Component is TStaticText then
|
||||
begin
|
||||
(Component as TStaticText).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TStaticText).Caption);
|
||||
(Component as TStaticText).Caption := FManager.Data.ReadString(Section,Indent,(Component as TStaticText).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TGroupBox
|
||||
if Component is TGroupBox then
|
||||
begin
|
||||
(Component as TGroupBox).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TGroupBox).Caption);
|
||||
(Component as TGroupBox).Caption := FManager.Data.ReadString(Section,Indent,(Component as TGroupBox).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TRadioButton
|
||||
if Component is TRadioButton then
|
||||
begin
|
||||
(Component as TRadioButton).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TRadioButton).Caption);
|
||||
(Component as TRadioButton).Caption := FManager.Data.ReadString(Section,Indent,(Component as TRadioButton).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TPanel
|
||||
if Component is TPanel then
|
||||
begin
|
||||
(Component as TPanel).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TPanel).Caption);
|
||||
(Component as TPanel).Caption := FManager.Data.ReadString(Section,Indent,(Component as TPanel).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TRadioGroup
|
||||
if Component is TRadioGroup then
|
||||
begin
|
||||
(Component as TRadioGroup).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TRadioGroup).Caption);
|
||||
(Component as TRadioGroup).Caption := FManager.Data.ReadString(Section,Indent,(Component as TRadioGroup).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TStatusBar
|
||||
if Component is TStatusBar then
|
||||
begin
|
||||
(Component as TStatusBar).SimpleText := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TStatusBar).SimpleText);
|
||||
(Component as TStatusBar).SimpleText := FManager.Data.ReadString(Section,Indent,(Component as TStatusBar).SimpleText);
|
||||
Exit;
|
||||
end;
|
||||
//TTabSheet
|
||||
if Component is TTabSheet then
|
||||
begin
|
||||
(Component as TTabSheet).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TTabSheet).Caption);
|
||||
(Component as TTabSheet).Caption := FManager.Data.ReadString(Section,Indent,(Component as TTabSheet).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TOpenDialog
|
||||
if Component is TOpenDialog then
|
||||
begin
|
||||
(Component as TOpenDialog).Title := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TOpenDialog).Title);
|
||||
(Component as TOpenDialog).Title := FManager.Data.ReadString(Section,Indent,(Component as TOpenDialog).Title);
|
||||
Exit;
|
||||
end;
|
||||
//TRichEdit
|
||||
if Component is TRichEdit then
|
||||
begin
|
||||
(Component as TRichEdit).Text := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TRichEdit).Text);
|
||||
(Component as TRichEdit).Text := FManager.Data.ReadString(Section,Indent,(Component as TRichEdit).Text);
|
||||
Exit;
|
||||
end;
|
||||
//TMenuItem
|
||||
if Component is TMenuItem then
|
||||
begin
|
||||
(Component as TMenuItem).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TMenuItem).Caption);
|
||||
(Component as TMenuItem).Caption := FManager.Data.ReadString(Section,Indent,(Component as TMenuItem).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TBitBtn
|
||||
if Component is TBitBtn then
|
||||
begin
|
||||
(Component as TBitBtn).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TBitBtn).Caption);
|
||||
(Component as TBitBtn).Caption := FManager.Data.ReadString(Section,Indent,(Component as TBitBtn).Caption);
|
||||
Exit;
|
||||
end;
|
||||
//TSpeedButton
|
||||
if Component is TSpeedButton then
|
||||
begin
|
||||
(Component as TSpeedButton).Caption := (Collection as TLocalizationReferences).FManager.Data.ReadString(Section,Indent,(Component as TSpeedButton).Caption);
|
||||
(Component as TSpeedButton).Caption := FManager.Data.ReadString(Section,Indent,(Component as TSpeedButton).Caption);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLocalizationApplier.ApplyToForm(Form: TCustomForm);
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
if Assigned(Form) = True then
|
||||
begin
|
||||
ApplyToComponent(Form,'',Form.Name);
|
||||
for Index := 0 to Form.ComponentCount - 1 do
|
||||
begin
|
||||
ApplyToComponent(Form.Components[Index],Form.Name,Form.Components[Index].Name);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLocalizationApplier.ApplyToAll;
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
for Index := 0 to Screen.CustomFormCount - 1 do
|
||||
begin
|
||||
ApplyToForm(Screen.Forms[Index]);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ ----------------------------------------------------------------------------
|
||||
TLocalizationManager
|
||||
---------------------------------------------------------------------------- }
|
||||
@@ -1028,6 +1206,7 @@ begin
|
||||
FLocalizations := TLocalizations.Create(TLocalization,Self);
|
||||
FData := TLocalizationData.Create(Self);
|
||||
FReferences := TLocalizationReferences.Create(TLocalizationReference,Self);
|
||||
FApplier := TLocalizationApplier.Create(Self);
|
||||
FCurrent := -1;
|
||||
FIgnoreCase := True;
|
||||
end;
|
||||
@@ -1038,6 +1217,7 @@ begin
|
||||
FLocalizations.Free;
|
||||
FData.Free;
|
||||
FReferences.Free;
|
||||
FApplier.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@@ -1076,7 +1256,7 @@ begin
|
||||
OnChange(Self,FCurrent,Value);
|
||||
end;
|
||||
FCurrent := Value;
|
||||
FReferences.Apply;
|
||||
FApplier.Apply;
|
||||
end;
|
||||
|
||||
procedure TLocalizationManager.SetIgnoreCase(Value: Boolean);
|
||||
|
@@ -220,6 +220,8 @@ type
|
||||
function ArrayPosRef(const AValue: String; const AArray: array of TStringRefDataArrayReferenceData; IgnoreCase: Boolean = False): Integer; overload;
|
||||
function ArrayPosRef(const AValue: Integer; const AArray: array of TIntegerRefDataArrayReferenceData): Integer; overload;
|
||||
function ArrayPosRef(const AValue: Extended; const AArray: array of TFloatRefDataArrayReferenceData): Integer; overload;
|
||||
function ArrayPosType(AValue: TClass; AArray: array of TClass): Integer; overload;
|
||||
function ArrayPosType(AValue: TClass; AArray: array of TObject): Integer; overload;
|
||||
{ TComponent Laden/Speichern }
|
||||
procedure ComponentSaveToFile(const FileName: String; Component: TComponent);
|
||||
procedure ComponentLoadFromFile(const FileName: String; Component: TComponent);
|
||||
@@ -982,6 +984,36 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ArrayPosType(AValue: TClass; AArray: array of TClass): Integer;
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
Result := Low(AArray) - 1;
|
||||
for Index := Low(AArray) to High(AArray) do
|
||||
begin
|
||||
if AArray[Index] = AValue then
|
||||
begin
|
||||
Result := Index;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ArrayPosType(AValue: TClass; AArray: array of TObject): Integer;
|
||||
var
|
||||
Index: Integer;
|
||||
begin
|
||||
Result := Low(AArray) - 1;
|
||||
for Index := Low(AArray) to High(AArray) do
|
||||
begin
|
||||
if AArray[Index] is AValue then
|
||||
begin
|
||||
Result := Index;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ExtractUserName(const Owner: String): String;
|
||||
var
|
||||
Index: Integer;
|
||||
|
Reference in New Issue
Block a user