POChecker: store total translation statistics in TPOFamilyList

git-svn-id: trunk@62834 -
This commit is contained in:
maxim 2020-03-31 16:21:23 +00:00
parent 7bf136d6ac
commit 056c393c8f
3 changed files with 27 additions and 37 deletions

View File

@ -397,8 +397,6 @@ end;
procedure TPoCheckerForm.RunSelectedTests;
var
TestTypes: TPoTestTypes;
TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer;
TotalPercTranslated: Double;
ResultDlg: TResultDlgForm;
mr: TModalResult;
begin
@ -413,7 +411,7 @@ begin
try
PoFamilyList.TestTypes := TestTypes;
PoFamilyList.RunTests(TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount, TotalPercTranslated);
PoFamilyList.RunTests;
PoFamilyList.InfoLog.Insert(0, sLastSearchPath);
PoFamilyList.InfoLog.Insert(1, SelectDirectoryDialog.FileName);
@ -424,11 +422,6 @@ begin
ResultDlg := TResultDlgForm.Create(nil);
try
ResultDlg.FTotalTranslated := TotalTranslatedCount;
ResultDlg.FTotalUntranslated := TotalUntranslatedCount;
ResultDlg.FTotalFuzzy := TotalFuzzyCount;
ResultDlg.FTotalPercTranslated := TotalPercTranslated;
ResultDlg.Settings := FPoCheckerSettings;
mr := ResultDlg.ShowModal;
finally

View File

@ -7,7 +7,7 @@ interface
Uses
Classes, SysUtils, ContNrs, LCLProc, LazFileUtils,
//{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF},
PoFamilies, PoCheckerConsts;
PoFamilies, PoCheckerConsts, Translations;
type
@ -20,6 +20,7 @@ type
FOnTestEnd: TTestEndEvent;
FOnTestStart: TTestStartEvent;
FPoFamilyStats: TPoFamilyStats;
FPoFamilyListStats: TTranslationStatistics;
FTestTypes: TPoTestTypes;
function GetItem(Index: Integer): TPoFamily;
//procedure SetItem(Index: Integer; AValue: TPoFamily);
@ -34,10 +35,12 @@ type
destructor Destroy; override;
procedure Add(PoFamily: TPofamily);
function Count: Integer;
procedure RunTests(out TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer; out TotalPercTranslated: Double);
function StatPerc(Value: Integer): Double;
procedure RunTests;
property LangID: TLangID read FLangID;
property Items[Index: Integer]: TPoFamily read GetItem; // write SetItem;
property PoFamilyStats: TPoFamilyStats read FPoFamilyStats;
property PoFamilyListStats: TTranslationStatistics read FPoFamilyListStats;
property TestTypes: TPoTestTypes read FTestTypes write FTestTypes;
property OnTestStart: TTestStartEvent read FOnTestStart write FOnTestStart;
property OnTestEnd: TTestEndEvent read FOnTestEnd write FOnTestEnd;
@ -131,7 +134,12 @@ begin
Result := FList.Count;
end;
procedure TPoFamilyList.RunTests(out TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer; out TotalPercTranslated: Double);
function TPoFamilyList.StatPerc(Value: Integer): Double;
begin
Result := 100 * Value / (PoFamilyListStats.Translated + PoFamilyListStats.Untranslated + PoFamilyListStats.Fuzzy);
end;
procedure TPoFamilyList.RunTests;
var
ErrorCount, NonFuzzyErrorCount, WarningCount: Integer;
Index, ThisErrorCount, ThisNonFuzzyErrorCount, ThisWarningCount: Integer;
@ -141,9 +149,9 @@ begin
ErrorCount := NoError;
NonFuzzyErrorCount := NoError;
WarningCount := NoError;
TotalTranslatedCount := 0;
TotalUntranslatedCount := 0;
TotalFuzzyCount := 0;
FPoFamilyListStats.Translated := 0;
FPoFamilyListStats.Untranslated := 0;
FPoFamilyListStats.Fuzzy := 0;
FPoFamilyStats.Clear;
for Index := 0 to FList.Count - 1 do
begin
@ -156,13 +164,11 @@ begin
ErrorCount := ErrorCount + ThisErrorCount;
NonFuzzyErrorCount := NonFuzzyErrorCount + ThisNonFuzzyErrorCount;
WarningCount := WarningCount + ThisWarningCount;
TotalTranslatedCount := TotalTranslatedCount + ThisTranslatedCount;
TotalUntranslatedCount := TotalUntranslatedCount + ThisUntranslatedCount;
TotalFuzzyCount := TotalFuzzyCount + ThisFuzzyCount;
FPoFamilyListStats.Translated := PoFamilyListStats.Translated + ThisTranslatedCount;
FPoFamilyListStats.Untranslated := PoFamilyListStats.Untranslated + ThisUntranslatedCount;
FPoFamilyListStats.Fuzzy := PoFamilyListStats.Fuzzy + ThisFuzzyCount;
end;
TotalPercTranslated := 100 * TotalTranslatedCount / (TotalTranslatedCount + TotalUntranslatedCount + TotalFuzzyCount);
if NonFuzzyErrorCount > 0 then
InfoLog.Add(Format(sTotalErrorsNonFuzzy, [ErrorCount, NonFuzzyErrorCount]))
else
@ -170,15 +176,15 @@ begin
if FLangID <> lang_all then
begin
InfoLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
InfoLog.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
InfoLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(PoFamilyListStats.Untranslated)]));
InfoLog.Add(Format(sTotalFuzzyStrings, [IntToStr(PoFamilyListStats.Fuzzy)]));
InfoLog.Add('');
InfoLog.Add(Format(sTotalTranslatedStrings, [IntToStr(TotalTranslatedCount), TotalPercTranslated]));
InfoLog.Add(Format(sTotalTranslatedStrings, [IntToStr(PoFamilyListStats.Translated), StatPerc(PoFamilyListStats.Translated)]));
StatLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
StatLog.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
StatLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(PoFamilyListStats.Untranslated)]));
StatLog.Add(Format(sTotalFuzzyStrings, [IntToStr(PoFamilyListStats.Fuzzy)]));
StatLog.Add('');
StatLog.Add(Format(sTotalTranslatedStrings, [IntToStr(TotalTranslatedCount), TotalPercTranslated]));
StatLog.Add(Format(sTotalTranslatedStrings, [IntToStr(PoFamilyListStats.Translated), StatPerc(PoFamilyListStats.Translated)]));
end;
DupLog.Add(Format(sTotalWarnings, [WarningCount]));

View File

@ -43,12 +43,6 @@ type
procedure LoadConfig;
procedure SaveConfig;
public
// The following fields keep translation statistics calculated when tests were performed.
// They will allow to avoid recalculation of these values in GraphStat form.
FTotalTranslated: Integer;
FTotalUntranslated: Integer;
FTotalFuzzy: Integer;
FTotalPercTranslated: Double;
property Settings: TPoCheckerSettings read FSettings write FSettings;
end;
@ -72,9 +66,6 @@ begin
PoHL := TSynPoSyn.Create(Self);
LogMemo.Highlighter := PoHL;
GraphStatBtn.Caption := sShowStatGraph;
FTotalTranslated := 0;
FTotalUntranslated := 0;
FTotalFuzzy := 0;
end;
procedure TResultDlgForm.CopyMenuItemClick(Sender: TObject);
@ -127,11 +118,11 @@ begin
if PoFamilyList.LangID <> lang_all then
begin
GraphStatForm.TranslatedLabel.Caption := Format(sTranslatedStringsTotal, [
IntToStr(FTotalTranslated), FTotalPercTranslated]);
IntToStr(PoFamilyList.PoFamilyListStats.Translated), PoFamilyList.StatPerc(PoFamilyList.PoFamilyListStats.Translated)]);
GraphStatForm.UnTranslatedLabel.Caption := Format(sUntranslatedStringsTotal
, [IntToStr(FTotalUntranslated)]);
, [IntToStr(PoFamilyList.PoFamilyListStats.Untranslated)]);
GraphStatForm.FuzzyLabel.Caption := Format(sFuzzyStringsTotal, [IntToStr(
FTotalFuzzy)]);
PoFamilyList.PoFamilyListStats.Fuzzy)]);
end
else
begin