mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 12:12:47 +02:00
POChecker: moved log handling code to TPOFamilyList class, where it really belongs to
git-svn-id: trunk@62030 -
This commit is contained in:
parent
d24501ac43
commit
04138e9fe7
@ -73,8 +73,8 @@ type
|
|||||||
procedure SetTestTypeCheckBoxes(TestTypes: TPoTestTypes);
|
procedure SetTestTypeCheckBoxes(TestTypes: TPoTestTypes);
|
||||||
procedure ShowError(const Msg: string);
|
procedure ShowError(const Msg: string);
|
||||||
procedure ScanDirectory(ADir: String);
|
procedure ScanDirectory(ADir: String);
|
||||||
function TryCreatepoFamilyList(var MasterList, SL: TStringList; const LangID: TLangID): Boolean;
|
function TryCreatepoFamilyList(var MasterList: TStringList; const LangID: TLangID): Boolean;
|
||||||
procedure RunSelectedTests(var SL, StatL, DupL: TStringList);
|
procedure RunSelectedTests;
|
||||||
procedure ClearStatusBar;
|
procedure ClearStatusBar;
|
||||||
procedure UpdateGUI(HasSelection: Boolean);
|
procedure UpdateGUI(HasSelection: Boolean);
|
||||||
function GetSelectedMasterFiles: TStringList;
|
function GetSelectedMasterFiles: TStringList;
|
||||||
@ -216,25 +216,19 @@ end;
|
|||||||
|
|
||||||
procedure TPoCheckerForm.RunToolButtonClick(Sender: TObject);
|
procedure TPoCheckerForm.RunToolButtonClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
AMasterList, SL, StatL, DupL: TStringList;
|
AMasterList: TStringList;
|
||||||
LangIdx: Integer;
|
LangIdx: Integer;
|
||||||
ALangID: TLangID;
|
ALangID: TLangID;
|
||||||
begin
|
begin
|
||||||
LangIdx := LangFilter.ItemIndex;
|
LangIdx := LangFilter.ItemIndex;
|
||||||
ALangID := LangFilterIndexToLangID(LangIdx);
|
ALangID := LangFilterIndexToLangID(LangIdx);
|
||||||
SL := TStringList.Create;
|
|
||||||
StatL := TStringList.Create;
|
|
||||||
DupL := TStringList.Create;
|
|
||||||
AMasterList := GetSelectedMasterFiles;
|
AMasterList := GetSelectedMasterFiles;
|
||||||
try
|
try
|
||||||
if TryCreatePoFamilyList(AMasterList, SL, ALangID) then
|
if TryCreatePoFamilyList(AMasterList, ALangID) then
|
||||||
RunSelectedTests(SL, StatL, DupL)
|
RunSelectedTests
|
||||||
else
|
else
|
||||||
ShowError(sSelectedTranslationsAreNotAvailable);
|
ShowError(sSelectedTranslationsAreNotAvailable);
|
||||||
finally
|
finally
|
||||||
SL.Free;
|
|
||||||
StatL.Free;
|
|
||||||
DupL.Free;
|
|
||||||
AMasterList.Free;
|
AMasterList.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -398,22 +392,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TPoCheckerForm.TryCreatepoFamilyList(var MasterList, SL: TStringList;
|
function TPoCheckerForm.TryCreatepoFamilyList(var MasterList: TStringList;
|
||||||
const LangID: TLangID): Boolean;
|
const LangID: TLangID): Boolean;
|
||||||
var
|
|
||||||
FamilyMsg: String;
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
try
|
try
|
||||||
if Assigned(PoFamilyList) then
|
if Assigned(PoFamilyList) then
|
||||||
PoFamilyList.Free;
|
PoFamilyList.Free;
|
||||||
PoFamilyList := TPoFamilyList.Create(MasterList, LangID, FamilyMsg);
|
PoFamilyList := TPoFamilyList.Create(MasterList, LangID);
|
||||||
if FamilyMsg <> '' then
|
|
||||||
begin
|
|
||||||
FamilyMsg := Format(sFilesNotFoundAndRemoved,[FamilyMsg]);
|
|
||||||
SL.AddText(FamilyMsg);
|
|
||||||
SL.Add('');
|
|
||||||
end;
|
|
||||||
PoFamilyList.OnTestStart := @OnTestStart;
|
PoFamilyList.OnTestStart := @OnTestStart;
|
||||||
PoFamilyList.OnTestEnd := @OnTestEnd;
|
PoFamilyList.OnTestEnd := @OnTestEnd;
|
||||||
Result := PoFamilyList.Count <> 0;
|
Result := PoFamilyList.Count <> 0;
|
||||||
@ -423,11 +409,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TPoCheckerForm.RunSelectedTests(var SL, StatL, DupL: TStringList);
|
procedure TPoCheckerForm.RunSelectedTests;
|
||||||
var
|
var
|
||||||
TestTypes: TPoTestTypes;
|
TestTypes: TPoTestTypes;
|
||||||
TestOptions: TPoTestOptions;
|
TestOptions: TPoTestOptions;
|
||||||
ErrorCount, NonFuzzyErrorCount, WarningCount: integer;
|
|
||||||
TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer;
|
TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer;
|
||||||
TotalPercTranslated: Double;
|
TotalPercTranslated: Double;
|
||||||
ResultDlg: TResultDlgForm;
|
ResultDlg: TResultDlgForm;
|
||||||
@ -446,37 +431,14 @@ begin
|
|||||||
PoFamilyList.TestTypes := TestTypes;
|
PoFamilyList.TestTypes := TestTypes;
|
||||||
PoFamilyList.TestOptions := TestOptions;
|
PoFamilyList.TestOptions := TestOptions;
|
||||||
|
|
||||||
PoFamilyList.RunTests(ErrorCount, NonFuzzyErrorCount, WarningCount, TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount, SL, StatL, DupL);
|
PoFamilyList.RunTests(TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount, TotalPercTranslated);
|
||||||
//debugln('RunSelectedTests: ', Format(sTotalErrors, [ErrorCount]));
|
|
||||||
//debugln(' ', Format(sTotalWarnings, [WarningCount]));
|
|
||||||
TotalPercTranslated := 100 * TotalTranslatedCount / (TotalTranslatedCount + TotalUntranslatedCount + TotalFuzzyCount);
|
|
||||||
|
|
||||||
SL.Insert(0, sLastSearchPath);
|
PoFamilyList.InfoLog.Insert(0, sLastSearchPath);
|
||||||
SL.Insert(1, SelectDirectoryDialog.FileName);
|
PoFamilyList.InfoLog.Insert(1, SelectDirectoryDialog.FileName);
|
||||||
SL.Insert(2, '');
|
PoFamilyList.InfoLog.Insert(2, '');
|
||||||
SL.Insert(3, sLanguage);
|
PoFamilyList.InfoLog.Insert(3, sLanguage);
|
||||||
SL.Insert(4, LangFilter.Text);
|
PoFamilyList.InfoLog.Insert(4, LangFilter.Text);
|
||||||
SL.Insert(5, '');
|
PoFamilyList.InfoLog.Insert(5, '');
|
||||||
|
|
||||||
if NonFuzzyErrorCount > 0 then
|
|
||||||
SL.Add(Format(sTotalErrorsNonFuzzy, [ErrorCount, NonFuzzyErrorCount]))
|
|
||||||
else
|
|
||||||
SL.Add(Format(sTotalErrors, [ErrorCount]));
|
|
||||||
|
|
||||||
if not (ptoFindAllChildren in TestOptions) then
|
|
||||||
begin
|
|
||||||
SL.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
|
|
||||||
SL.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
|
|
||||||
SL.Add('');
|
|
||||||
SL.Add(Format(sTotalTranslatedStrings, [IntToStr(TotalTranslatedCount), TotalPercTranslated]));
|
|
||||||
|
|
||||||
StatL.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
|
|
||||||
StatL.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
|
|
||||||
StatL.Add('');
|
|
||||||
StatL.Add(Format(sTotalTranslatedStrings, [IntToStr(TotalTranslatedCount), TotalPercTranslated]));
|
|
||||||
end;
|
|
||||||
|
|
||||||
DupL.Add(Format(sTotalWarnings, [WarningCount]));
|
|
||||||
|
|
||||||
ResultDlg := TResultDlgForm.Create(nil);
|
ResultDlg := TResultDlgForm.Create(nil);
|
||||||
try
|
try
|
||||||
@ -485,10 +447,10 @@ begin
|
|||||||
ResultDlg.FTotalUntranslated := TotalUntranslatedCount;
|
ResultDlg.FTotalUntranslated := TotalUntranslatedCount;
|
||||||
ResultDlg.FTotalFuzzy := TotalFuzzyCount;
|
ResultDlg.FTotalFuzzy := TotalFuzzyCount;
|
||||||
ResultDlg.FTotalPercTranslated := TotalPercTranslated;
|
ResultDlg.FTotalPercTranslated := TotalPercTranslated;
|
||||||
ResultDlg.Log.Assign(SL);
|
ResultDlg.Log.Assign(PoFamilyList.InfoLog);
|
||||||
ResultDlg.StatLog.Assign(StatL);
|
ResultDlg.StatLog.Assign(PoFamilyList.StatLog);
|
||||||
|
|
||||||
ResultDlg.DupLog.Assign(DupL);
|
ResultDlg.DupLog.Assign(PoFamilyList.DupLog);
|
||||||
|
|
||||||
ResultDlg.PoFamilyList := PoFamilyList;
|
ResultDlg.PoFamilyList := PoFamilyList;
|
||||||
ResultDlg.PoFamilyStats := PoFamilyList.PoFamilyStats;
|
ResultDlg.PoFamilyStats := PoFamilyList.PoFamilyStats;
|
||||||
|
@ -28,13 +28,14 @@ type
|
|||||||
procedure DoTestStart(const ATestName, APoFileName: String);
|
procedure DoTestStart(const ATestName, APoFileName: String);
|
||||||
procedure DoTestEnd(const ATestName: String; const ErrorCount: Integer);
|
procedure DoTestEnd(const ATestName: String; const ErrorCount: Integer);
|
||||||
public
|
public
|
||||||
constructor Create(AMasterList: TStrings; ALangID: TLangID; out Msg: String);
|
InfoLog: TStringList;
|
||||||
|
StatLog: TStringList;
|
||||||
|
DupLog: TStringList;
|
||||||
|
constructor Create(AMasterList: TStrings; ALangID: TLangID);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Add(PoFamily: TPofamily);
|
procedure Add(PoFamily: TPofamily);
|
||||||
function Count: Integer;
|
function Count: Integer;
|
||||||
procedure RunTests(out ErrorCount, NonFuzzyErrorCount, WarningCount,
|
procedure RunTests(out TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer; out TotalPercTranslated: Double);
|
||||||
TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer;
|
|
||||||
ErrorLog, StatLog, DupLog: TStringList);
|
|
||||||
property Items[Index: Integer]: TPoFamily read GetItem; // write SetItem;
|
property Items[Index: Integer]: TPoFamily read GetItem; // write SetItem;
|
||||||
property PoFamilyStats: TPoFamilyStats read FPoFamilyStats;
|
property PoFamilyStats: TPoFamilyStats read FPoFamilyStats;
|
||||||
property TestTypes: TPoTestTypes read FTestTypes write FTestTypes;
|
property TestTypes: TPoTestTypes read FTestTypes write FTestTypes;
|
||||||
@ -63,12 +64,15 @@ begin
|
|||||||
if Assigned(FOnTestEnd) then FOnTestEnd(ATestName, ErrorCount);
|
if Assigned(FOnTestEnd) then FOnTestEnd(ATestName, ErrorCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TPoFamilyList.Create(AMasterList: TStrings; ALangID: TLangID; out Msg: String);
|
constructor TPoFamilyList.Create(AMasterList: TStrings; ALangID: TLangID);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
MasterName, ChildName, MasterMsg, ChildMsg: String;
|
MasterName, ChildName, MasterMsg, ChildMsg: String;
|
||||||
APoFamily: TPoFamily;
|
APoFamily: TPoFamily;
|
||||||
begin
|
begin
|
||||||
|
InfoLog := TStringList.Create;
|
||||||
|
StatLog := TStringList.Create;
|
||||||
|
DupLog := TStringList.Create;
|
||||||
FList := TFPObjectList.Create(True);
|
FList := TFPObjectList.Create(True);
|
||||||
MasterMsg := '';
|
MasterMsg := '';
|
||||||
ChildMsg := '';
|
ChildMsg := '';
|
||||||
@ -95,15 +99,22 @@ begin
|
|||||||
else
|
else
|
||||||
MasterMsg := MasterMsg + Format('"%s"',[MasterName]) + LineEnding;
|
MasterMsg := MasterMsg + Format('"%s"',[MasterName]) + LineEnding;
|
||||||
end;
|
end;
|
||||||
if (MasterMsg <> '') and (ChildMsg <> '') then
|
if MasterMsg <> '' then
|
||||||
MasterMsg := MasterMsg + LineEnding;
|
MasterMsg := MasterMsg + LineEnding;
|
||||||
Msg := MasterMsg + ChildMsg;
|
if ChildMsg <> '' then
|
||||||
|
ChildMsg := ChildMsg + LineEnding;
|
||||||
|
MasterMsg := MasterMsg + ChildMsg;
|
||||||
|
if MasterMsg <> '' then
|
||||||
|
InfoLog.AddText(Format(sFilesNotFoundAndRemoved,[MasterMsg]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TPoFamilyList.Destroy;
|
destructor TPoFamilyList.Destroy;
|
||||||
begin
|
begin
|
||||||
//debugln('TPoFamilyList.Destroy: FList.Count = ',DbgS(FList.Count));
|
//debugln('TPoFamilyList.Destroy: FList.Count = ',DbgS(FList.Count));
|
||||||
PoFamilyStats.Free;
|
PoFamilyStats.Free;
|
||||||
|
InfoLog.Free;
|
||||||
|
StatLog.Free;
|
||||||
|
DupLog.Free;
|
||||||
FList.Free;
|
FList.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -118,9 +129,9 @@ begin
|
|||||||
Result := FList.Count;
|
Result := FList.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPoFamilyList.RunTests(out ErrorCount, NonFuzzyErrorCount, WarningCount, TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer;
|
procedure TPoFamilyList.RunTests(out TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer; out TotalPercTranslated: Double);
|
||||||
ErrorLog, StatLog, DupLog: TStringList);
|
|
||||||
var
|
var
|
||||||
|
ErrorCount, NonFuzzyErrorCount, WarningCount: Integer;
|
||||||
Index, ThisErrorCount, ThisNonFuzzyErrorCount, ThisWarningCount: Integer;
|
Index, ThisErrorCount, ThisNonFuzzyErrorCount, ThisWarningCount: Integer;
|
||||||
ThisTranslatedCount, ThisUntranslatedCount, ThisFuzzyCount: Integer;
|
ThisTranslatedCount, ThisUntranslatedCount, ThisFuzzyCount: Integer;
|
||||||
PoFamily: TPoFamily;
|
PoFamily: TPoFamily;
|
||||||
@ -143,7 +154,7 @@ begin
|
|||||||
PoFamily.OnTestEnd := FOnTestEnd;
|
PoFamily.OnTestEnd := FOnTestEnd;
|
||||||
PoFamily.TestTypes := FTesttypes;
|
PoFamily.TestTypes := FTesttypes;
|
||||||
PoFamily.TestOptions := FTestOptions;
|
PoFamily.TestOptions := FTestOptions;
|
||||||
PoFamily.RunTests(ThisErrorCount, ThisNonFuzzyErrorCount, ThisWarningCount, ThisTranslatedCount, ThisUntranslatedCount, ThisFuzzyCount, ErrorLog, StatLog, DupLog);
|
PoFamily.RunTests(ThisErrorCount, ThisNonFuzzyErrorCount, ThisWarningCount, ThisTranslatedCount, ThisUntranslatedCount, ThisFuzzyCount, InfoLog, StatLog, DupLog);
|
||||||
PoFamily.PoFamilyStats.AddItemsTo(FPoFamilyStats);
|
PoFamily.PoFamilyStats.AddItemsTo(FPoFamilyStats);
|
||||||
ErrorCount := ErrorCount + ThisErrorCount;
|
ErrorCount := ErrorCount + ThisErrorCount;
|
||||||
NonFuzzyErrorCount := NonFuzzyErrorCount + ThisNonFuzzyErrorCount;
|
NonFuzzyErrorCount := NonFuzzyErrorCount + ThisNonFuzzyErrorCount;
|
||||||
@ -152,6 +163,28 @@ begin
|
|||||||
TotalUntranslatedCount := TotalUntranslatedCount + ThisUntranslatedCount;
|
TotalUntranslatedCount := TotalUntranslatedCount + ThisUntranslatedCount;
|
||||||
TotalFuzzyCount := TotalFuzzyCount + ThisFuzzyCount;
|
TotalFuzzyCount := TotalFuzzyCount + ThisFuzzyCount;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TotalPercTranslated := 100 * TotalTranslatedCount / (TotalTranslatedCount + TotalUntranslatedCount + TotalFuzzyCount);
|
||||||
|
|
||||||
|
if NonFuzzyErrorCount > 0 then
|
||||||
|
InfoLog.Add(Format(sTotalErrorsNonFuzzy, [ErrorCount, NonFuzzyErrorCount]))
|
||||||
|
else
|
||||||
|
InfoLog.Add(Format(sTotalErrors, [ErrorCount]));
|
||||||
|
|
||||||
|
if not (ptoFindAllChildren in TestOptions) then
|
||||||
|
begin
|
||||||
|
InfoLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
|
||||||
|
InfoLog.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
|
||||||
|
InfoLog.Add('');
|
||||||
|
InfoLog.Add(Format(sTotalTranslatedStrings, [IntToStr(TotalTranslatedCount), TotalPercTranslated]));
|
||||||
|
|
||||||
|
StatLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
|
||||||
|
StatLog.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
|
||||||
|
StatLog.Add('');
|
||||||
|
StatLog.Add(Format(sTotalTranslatedStrings, [IntToStr(TotalTranslatedCount), TotalPercTranslated]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
DupLog.Add(Format(sTotalWarnings, [WarningCount]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user