PoChecker:

- implement option to ignore translated strings that are marked as "fuzzy".
- separate TestTypes from TestOptions.
- fix a resource string.
- regenerated po-files.

git-svn-id: trunk@46056 -
This commit is contained in:
bart 2014-08-21 18:27:29 +00:00
parent d097ee99f8
commit 01f1750902
16 changed files with 239 additions and 107 deletions

View File

@ -43,7 +43,6 @@
<Unit0>
<Filename Value="pochecker.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="pochecker"/>
</Unit0>
<Unit1>
<Filename Value="..\pofamilies.pp"/>
@ -56,7 +55,6 @@
<ComponentName Value="ResultDlgForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="ResultDlg"/>
</Unit2>
<Unit3>
<Filename Value="..\simplepofiles.pp"/>

View File

@ -107,6 +107,10 @@ msgstr "GUI pomůcka pro kontrolu po souborů"
msgid "Identifier [%s] not found in %s"
msgstr "Identifikátor [%s] nenalezen v %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
#| msgid "[Line: %d] Incompatible format() arguments for:"
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
@ -142,6 +146,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Nejsou vybrány žádné testy."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Nalezeno %d chyb."
@ -213,7 +221,9 @@ msgid "Select test types"
msgstr "Vybrat typy testu"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Nalezeno celkem %d chyb / varování."
#: pocheckerconsts.stotalwarnings

View File

@ -104,6 +104,10 @@ msgstr "po-Datei-Überprüfungswerkzeug"
msgid "Identifier [%s] not found in %s"
msgstr "Bezeichner [%s] nicht gefunden in %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
msgstr "[Zeile: %d] Inkompatible und/oder ungültige Format()-Argumente für:"
@ -139,6 +143,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Es wurden keine Tests ausgewählt."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "%d Fehler gefunden."
@ -209,7 +217,9 @@ msgid "Select test types"
msgstr "Test-Typen"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Insgesamt %d Fehler / Warnungen gefunden"
#: pocheckerconsts.stotalwarnings

View File

@ -103,6 +103,10 @@ msgstr "GUI de herramienta de comprobación de archivos PO"
msgid "Identifier [%s] not found in %s"
msgstr "Identificador [%s] no se encuentra en %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
#, fuzzy
#| msgid "[Line: %d] Incompatible format() arguments for:"
@ -139,6 +143,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "No existen pruebas seleccionadas."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Encontrados %d errores."
@ -210,7 +218,9 @@ msgid "Select test types"
msgstr "Seleccione los tipos de prueba"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Total de errores / advertencias encontraron: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -105,6 +105,10 @@ msgstr "GUI Po-fájl ellenőrző eszköz"
msgid "Identifier [%s] not found in %s"
msgstr "A(z) %s azonosító nem található ebben: %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
msgstr "[Sor: %d] Nem megfelelő és/vagy érvénytelen format() paraméterek a következőben:"
@ -139,6 +143,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Egy teszt sincs teszt kiválasztva."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "%d hiba."
@ -209,7 +217,9 @@ msgid "Select test types"
msgstr "Teszt típusok kiválasztása"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Összes hiba / figyelmeztetés: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -103,6 +103,10 @@ msgstr "Strumento GUI di verifica di file po"
msgid "Identifier [%s] not found in %s"
msgstr "Identificatore [%s] non trovato in %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
msgstr "[Riga: %d] Argomenti di format()Incompatibili e/o non validi per:"
@ -137,6 +141,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Nessuna verifica selezionata"
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Riscontrati %d errori."
@ -206,7 +214,9 @@ msgid "Select test types"
msgstr "Seleziona i tipi di verifica"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Totale errori / avvertimenti: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -105,6 +105,10 @@ msgstr "GUI po ファイル検査ツール"
msgid "Identifier [%s] not found in %s"
msgstr "識別子 [%s] が %s 内にありません"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
msgstr "[行:%d] 互換性のないもしくは無効な format() の引数:"
@ -139,6 +143,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "テスト項目が選択されていません。"
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "%d 個のエラーが見つかりました。"
@ -210,7 +218,9 @@ msgid "Select test types"
msgstr "テスト項目を選択してください"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "エラー/警告の総数:%d"
#: pocheckerconsts.stotalwarnings

View File

@ -105,6 +105,10 @@ msgstr "Įrankio PO failų tikrinimui grafinė sąsaja"
msgid "Identifier [%s] not found in %s"
msgstr "Ieškota identifikatoriaus [%s], tačiau %s jo neturi"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
#, fuzzy
#| msgid "[Line: %d] Incompatible format() arguments for:"
@ -141,6 +145,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Būtina parinkti bent vieną testavimą."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Rasta klaidų: %d."
@ -210,7 +218,9 @@ msgid "Select test types"
msgstr "Pažymėti testavimo tipus"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Viso rasta klaidų/perspėjimų: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -86,6 +86,10 @@ msgstr ""
msgid "Identifier [%s] not found in %s"
msgstr ""
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
msgstr ""
@ -117,6 +121,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr ""
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr ""
@ -184,7 +192,7 @@ msgid "Select test types"
msgstr ""
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr ""
#: pocheckerconsts.stotalwarnings

View File

@ -104,6 +104,10 @@ msgstr "Ferramenta GUI de verificação de arquivos PO"
msgid "Identifier [%s] not found in %s"
msgstr "Identificador [%s] não encontrado em %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
#| msgid "[Line: %d] Incompatible format() arguments for:"
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
@ -139,6 +143,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Nenhum teste selecionado."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Encontrados %d erros."
@ -210,7 +218,9 @@ msgid "Select test types"
msgstr "Selecionar tipos de teste"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Total de erros / avisos encontrados: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -103,6 +103,10 @@ msgstr "Средство проверки файлов PO"
msgid "Identifier [%s] not found in %s"
msgstr "Идентификатор [%s] не найден в %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
#| msgid "[Line: %d] Incompatible format() arguments for:"
msgid "[Line: %d] Incompatible and/or invalid format() arguments for:"
@ -138,6 +142,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Не выбрано ни одного теста."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Найдено ошибок: %d"
@ -209,7 +217,9 @@ msgid "Select test types"
msgstr "Выбор тестов"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Всего найдено ошибок и предупреждений: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -102,6 +102,10 @@ msgstr "GUI інструмент перевірки po-файлів"
msgid "Identifier [%s] not found in %s"
msgstr "Ідентифікатор [%s] не знайдений в %s"
#: pocheckerconsts.signorefuzzytranslations
msgid "Ignore translated strings marked as \"fuzzy\""
msgstr ""
#: pocheckerconsts.sincompatibleformatargs
#, fuzzy
#| msgid "[Line: %d] Incompatible format() arguments for:"
@ -138,6 +142,10 @@ msgstr ""
msgid "There are no tests selected."
msgstr "Не вибрано жодного тесту."
#: pocheckerconsts.snotetranslationisfuzzy
msgid "Note: translation is fuzzy"
msgstr ""
#: pocheckerconsts.snrerrorsfound
msgid "Found %d errors."
msgstr "Знайдено %d помилок."
@ -207,7 +215,9 @@ msgid "Select test types"
msgstr "Вибрати типи тестів"
#: pocheckerconsts.stotalerrors
msgid "Total errors / warnings found: %d"
#, fuzzy
#| msgid "Total errors / warnings found: %d"
msgid "Total errors found: %d"
msgstr "Знайдено всього помилок / попереджень: %d"
#: pocheckerconsts.stotalwarnings

View File

@ -19,7 +19,7 @@ resourcestring
sErrorOnCreate = 'Error creating an instance of TPoFamily:' + LineEnding + '%s';
sErrorOnCleanup = 'An unrecoverable error occurred' + LineEnding + '%s' + LineEnding + 'Please close the program';
sTotalErrors = 'Total errors / warnings found: %d';
sTotalErrors = 'Total errors found: %d';
sTotalWarnings = 'Total warnings found: %d';
sNoErrorsFound = 'No errors found';
sCurrentTest = 'Current Test:';
@ -47,6 +47,7 @@ resourcestring
+'values';
sCheckStatistics = 'Check percentage of (un)translated and fuzzy strings';
sFindAllTranslatedPoFiles = 'Find all translated po-files';
sIgnoreFuzzyTranslations = 'Ignore translated strings marked as "fuzzy"';
sIncompatibleFormatArgs = '[Line: %d] Incompatible and/or invalid format() arguments for:' ;
sNrErrorsFound = 'Found %d errors.';
@ -55,6 +56,8 @@ resourcestring
sIdentifierNotFoundIn = 'Identifier [%s] not found in %s';
sMissingMasterIdentifier = 'Identifier [%s] found in %s, but it does not exist in %s';
sLineNr = '[Line: %d]';
sNoteTranslationIsFuzzy = 'Note: translation is fuzzy';
sNrOfItemsMisMatch = 'Mismatch in number of items for master and child';
sNrOfItemsMismatchD = '%s: %d items';

View File

@ -1,10 +1,10 @@
object PoCheckerForm: TPoCheckerForm
Left = 318
Height = 311
Height = 342
Top = 163
Width = 581
Caption = 'GUI Po-file checking tool'
ClientHeight = 311
ClientHeight = 342
ClientWidth = 581
OnCreate = FormCreate
OnDestroy = FormDestroy
@ -15,23 +15,22 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Control = SelectTestLabel
AnchorSideTop.Side = asrBottom
Left = 201
Height = 152
Top = 26
Height = 154
Top = 29
Width = 373
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
Enabled = False
ItemHeight = 0
TabOrder = 0
TopIndex = -1
end
object SelectTestLabel: TLabel
AnchorSideLeft.Control = OpenBtn
AnchorSideLeft.Side = asrBottom
Left = 201
Height = 12
Height = 15
Top = 8
Width = 84
Width = 93
BorderSpacing.Left = 9
Caption = 'Select test types'
Font.Style = [fsBold]
@ -106,7 +105,7 @@ object PoCheckerForm: TPoCheckerForm
object StatusPanel: TPanel
Left = 0
Height = 49
Top = 262
Top = 293
Width = 581
Align = alBottom
BevelOuter = bvLowered
@ -115,9 +114,9 @@ object PoCheckerForm: TPoCheckerForm
TabOrder = 3
object CurTestHeaderLabel: TLabel
Left = 8
Height = 12
Height = 15
Top = 8
Width = 61
Width = 68
Caption = 'Current Test:'
ParentColor = False
end
@ -126,9 +125,9 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Control = CurTestHeaderLabel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 12
Top = 20
Width = 72
Height = 15
Top = 23
Width = 81
Caption = 'Current po-file:'
ParentColor = False
end
@ -137,10 +136,10 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CurTestHeaderLabel
AnchorSideTop.Side = asrCenter
Left = 75
Height = 12
Left = 82
Height = 15
Top = 8
Width = 61
Width = 69
BorderSpacing.Around = 6
Caption = 'CurTestLabel'
ParentColor = False
@ -150,10 +149,10 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CurPoHeaderLabel
AnchorSideTop.Side = asrCenter
Left = 86
Height = 12
Top = 20
Width = 53
Left = 95
Height = 15
Top = 23
Width = 61
BorderSpacing.Around = 6
Caption = 'CurPoLabel'
ParentColor = False
@ -161,9 +160,9 @@ object PoCheckerForm: TPoCheckerForm
end
object NoErrLabel: TLabel
Left = 8
Height = 22
Top = 234
Width = 145
Height = 25
Top = 262
Width = 146
Anchors = [akLeft, akBottom]
Caption = 'No errors found'
Font.Color = clGreen
@ -177,9 +176,9 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Control = SelectBasicBtn
AnchorSideTop.Side = asrBottom
Left = 201
Height = 24
Top = 215
Width = 149
Height = 19
Top = 220
Width = 156
BorderSpacing.Top = 6
Caption = 'Find all translated PO files'
TabOrder = 4
@ -190,7 +189,7 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Side = asrBottom
Left = 201
Height = 25
Top = 184
Top = 189
Width = 115
BorderSpacing.Top = 6
Caption = 'Select Basic Tests'
@ -204,7 +203,7 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Control = SelectBasicBtn
Left = 320
Height = 25
Top = 184
Top = 189
Width = 115
BorderSpacing.Left = 4
Caption = 'Select All Tests'
@ -218,7 +217,7 @@ object PoCheckerForm: TPoCheckerForm
AnchorSideTop.Control = SelectAllBtn
Left = 439
Height = 25
Top = 184
Top = 189
Width = 115
BorderSpacing.Left = 4
Caption = 'Unselect All Tests'
@ -226,6 +225,14 @@ object PoCheckerForm: TPoCheckerForm
OnClick = UnselectAllBtnClick
TabOrder = 7
end
object IgnoreFuzzyCheckBox: TCheckBox
Left = 201
Height = 19
Top = 240
Width = 152
Caption = 'sIgnoreFuzzyTranslations'
TabOrder = 8
end
object OpenDialog: TOpenDialog
Filter = 'po-files (*.po)|*.po|all files|*'
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]

View File

@ -38,6 +38,7 @@ type
{ TPoCheckerForm }
TPoCheckerForm = class(TForm)
IgnoreFuzzyCheckBox: TCheckBox;
UnselectAllBtn: TButton;
SelectAllBtn: TButton;
SelectBasicBtn: TButton;
@ -68,7 +69,8 @@ type
procedure OnTestStart(const ATestName, APoFileName: string);
procedure OnTestEnd(const ATestName: string; const ErrorCount: integer);
procedure FillTestListBox;
function GetOptionsFromListBox: TPoTestOptions;
function GetTestTypesFromListBox: TPoTestTypes;
function GetTestOptions: TPoTestOptions;
procedure ShowError(const Msg: string);
function TrySelectFile: boolean;
procedure RunSelectedTests;
@ -122,6 +124,7 @@ begin
Caption := sGUIPoFileCheckingTool;
SelectTestLabel.Caption := sSelectTestTypes;
FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles;
IgnoreFuzzyCheckBox.Caption := sIgnoreFuzzyTranslations;
OpenBtn.Caption := sOpenAPoFile;
RunBtn.Caption := sRunSelectedTests;
NoErrLabel.Caption := sNoErrorsFound;
@ -211,45 +214,52 @@ end;
procedure TPoCheckerForm.FillTestListBox;
var
Opt: TPoTestOption;
Typ: TPoTestType;
begin
for Opt := Low(PoTestOptionNames) to Pred(High(PoTestOptionNames)) do
case Opt of
ptoCheckNrOfItems:
for Typ := Low(PoTestTypeNames) to High(PoTestTypeNames) do
case Typ of
pttCheckNrOfItems:
TestListBox.Items.Add(sCheckNumberOfItems);
ptoCheckFormatArgs:
pttCheckFormatArgs:
TestListBox.Items.Add(sCheckForIncompatibleFormatArguments);
ptoCheckMissingIdentifiers:
pttCheckMissingIdentifiers:
TestListBox.Items.Add(sCheckMissingIdentifiers);
ptoCheckMismatchedOriginals:
pttCheckMismatchedOriginals:
TestListBox.Items.Add(sCheckForMismatchesInUntranslatedStrings);
ptoCheckDuplicateOriginals:
pttCheckDuplicateOriginals:
TestListBox.Items.Add(sCheckForDuplicateUntranslatedValues);
ptoCheckStatistics:
pttCheckStatistics:
TestListBox.Items.Add(sCheckStatistics);
else
TestListBox.Items.Add(PoTestOptionNames[Opt]);
TestListBox.Items.Add(PoTestTypeNames[Typ]);
end;
end;
function TPoCheckerForm.GetOptionsFromListBox: TPoTestOptions;
function TPoCheckerForm.GetTestTypesFromListBox: TPoTestTypes;
var
Opt: TPoTestOption;
Typ: TPoTestType;
Index: integer;
begin
Result := [];
for Opt := Low(TpoTestOption) to Pred(High(TPoTestOption)) do
for Typ := Low(TPoTestType) to High(TPoTestType) do
begin
Index := Ord(Opt);
Index := Ord(Typ);
if (Index < TestListBox.Count) then
begin
if TestListBox.Checked[Index] then
Result := Result + [Opt];
Result := Result + [Typ];
end;
end;
end;
function TPoCheckerForm.GetTestOptions: TPoTestOptions;
begin
Result := [];
if FindAllPOsCheckBox.Checked then
Result := Result + [High(TPoTestOption)];
Result := Result + [ptoFindAllChildren];
if IgnoreFuzzyCheckBox.Checked then
Result := Result + [ptoIgnoreFuzzyStrings];
end;
@ -330,30 +340,32 @@ end;
procedure TPoCheckerForm.RunSelectedTests;
var
Options: TPoTestOptions;
TestTypes: TPoTestTypes;
TestOptions: TPoTestOptions;
ErrorCount, WarningCount: integer;
SL: TStrings;
ResultDlg: TResultDlgForm;
begin
Options := GetOptionsFromListBox;
if (Options = []) then
TestTypes := GetTestTypesFromListBox;
if (TestTypes = []) then
begin
ShowError(sNoTestSelected);
Exit;
end;
TestOptions := GetTestOptions;
NoErrLabel.Visible := False;
Application.ProcessMessages;
SL := TStringList.Create;
try
StatusPanel.Enabled := True;
if (not (ptoFindAllChildren in Options)) and Assigned(PoFamily.Child) and
if (not (ptoFindAllChildren in TestOptions)) and Assigned(PoFamily.Child) and
(PoFamily.ChildName <> FChosenChildName) then
PoFamily.ChildName := FChosenChildName;
PoFamily.RunTests(Options, ErrorCount, WarningCount, SL);
PoFamily.RunTests(TestTypes, TestOptions, ErrorCount, WarningCount, SL);
debugln('RunSelectedTests: ', Format(sTotalErrors, [ErrorCount]));
debugln(' ', Format(sTotalWarnings, [WarningCount]));
if (ErrorCount > 0) or (WarningCount > 0) or
(ptoCheckStatistics in Options) then
(pttCheckStatistics in TestTypes) then
begin
SL.Add(Format(sTotalErrors, [ErrorCount]));
SL.Add(Format(sTotalWarnings, [WarningCount]));

View File

@ -13,23 +13,23 @@ uses
Type
TPoTestOption = (ptoCheckNrOfItems, ptoCheckFormatArgs, ptoCheckMissingIdentifiers,
ptoCheckMismatchedOriginals, ptoCheckDuplicateOriginals, ptoCheckStatistics,
ptoFindAllChildren);
TPoTestOptions = Set of TPoTestOption;
TPoTestType = (pttCheckNrOfItems, pttCheckFormatArgs, pttCheckMissingIdentifiers,
pttCheckMismatchedOriginals, pttCheckDuplicateOriginals, pttCheckStatistics);
TPoTestTypes = Set of TPoTestType;
TPoTestOption = (ptoFindAllChildren, ptoIgnoreFuzzyStrings);
TPoTestOptions = set of TPoTestOption;
const
optRunAllTests: TPoTestOptions = [];
optRunAllTestsOnAllChildren: TPoTestOptions = [];
optRunAllTests: TPoTestTypes = [];
PoTestOptionNames: array[TPoTestOption] of String = (
PoTestTypeNames: array[TPoTestType] of String = (
sCheckNumberOfItems,
sCheckForIncompatibleFormatArguments,
sCheckMissingIdentifiers,
sCheckForMismatchesInUntranslatedStrings,
sCheckForDuplicateUntranslatedValues,
sCheckStatistics,
sFindAllTranslatedPoFiles
sCheckStatistics
);
Type
@ -61,14 +61,15 @@ Type
protected
procedure CheckNrOfItems(out ErrorCount: Integer; ErrorLog: TStrings);
procedure CheckFormatArgs(out ErrorCount: Integer; ErrorLog: TStrings);
procedure CheckFormatArgs(out ErrorCount: Integer; ErrorLog: TStrings; IgnoreFuzzyStrings: Boolean);
procedure CheckMissingIdentifiers(out ErrorCount: Integer; ErrorLog: TStrings);
procedure CheckMismatchedOriginals(out ErrorCount: Integer; ErrorLog: TStrings);
procedure CheckDuplicateOriginals(out WarningCount: Integer; ErrorLog: TStrings);
procedure CheckStatistics(out WarningCount: Integer; ErrorLog: TStrings);
public
procedure RunTests(const Options: TPoTestOptions; out ErrorCount, WarningCount: Integer; ErrorLog: TStrings);
procedure RunTests(const TestTypes: TPoTestTypes; const TestOptions: TPoTestOptions;
out ErrorCount, WarningCount: Integer; ErrorLog: TStrings);
property Master: TSimplePoFile read FMaster;
property Child: TSimplePoFile read FChild;
@ -349,7 +350,7 @@ end;
procedure TPoFamily.CheckNrOfItems(out ErrorCount: Integer; ErrorLog: TStrings);
begin
//debugln('TPoFamily.CheckNrOfItems');
DoTestStart(PoTestOptionNames[ptoCheckNrOfItems], ShortChildName);
DoTestStart(PoTestTypeNames[pttCheckNrOfItems], ShortChildName);
if (FMaster.Count <> FChild.Count) then
begin
ErrorCount := 1;
@ -366,17 +367,18 @@ begin
ErrorLog.Add('');
end
else ErrorCount := NoError;
DoTestEnd(PoTestOptionNames[ptoCheckNrOfItems], ErrorCount);
DoTestEnd(PoTestTypeNames[pttCheckNrOfItems], ErrorCount);
//debugln('TPoFamily.CheckNrOfItemsMismatch: ',Dbgs(ErrorCount),' Errors');
end;
procedure TPoFamily.CheckFormatArgs(out ErrorCount: Integer; ErrorLog: TStrings);
procedure TPoFamily.CheckFormatArgs(out ErrorCount: Integer; ErrorLog: TStrings; IgnoreFuzzyStrings: Boolean);
var
i: Integer;
CPoItem: TPOFileItem;
IsFuzzy: Boolean;
begin
//debugln('TPoFamily.CheckFormatArgs');
DoTestStart(PoTestOptionNames[ptoCheckFormatArgs], ShortChildName);
DoTestStart(PoTestTypeNames[pttCheckFormatArgs], ShortChildName);
ErrorCount := NoError;
//for i := 0 to FMaster.Count - 1 do
for i := 0 to FChild.Count - 1 do
@ -387,7 +389,9 @@ begin
//CPoItem := FChild.FindPoItem(MPoItem.Identifier);
if Assigned(CPoItem) then
begin
if (Length(CPoItem.Translation) > 0) and (CompareFormatArgs(CPoItem.Original, CPoItem.Translation) = false) then
IsFuzzy := (Pos('fuzzy', CPoItem.Flags) > 0);
//if (IgnoreFuzzyStrings and IsFuzzy) then debugln('Skipping fuzzy translation: ',CPoItem.Translation);
if (Length(CPoItem.Translation) > 0) and (not (IgnoreFuzzyStrings and IsFuzzy)) and (not CompareFormatArgs(CPoItem.Original, CPoItem.Translation)) then
begin
if (ErrorCount = 0) then
begin
@ -402,6 +406,7 @@ begin
ErrorLog.Add(Format(sFormatArgsID,[sCommentIdentifier, CPoItem.Identifier]));
ErrorLog.Add(Format(sFormatArgsValues,[sMsgID,CPoItem.Original,sOriginal]));
ErrorLog.Add(Format(sFormatArgsValues,[sMsgStr,CPoItem.Translation,sTranslation]));
if IsFuzzy then ErrorLog.Add(sNoteTranslationIsFuzzy);
ErrorLog.Add('');
end;
end;
@ -413,7 +418,7 @@ begin
ErrorLog.Add('');
ErrorLog.Add('');
end;
DoTestEnd(PoTestOptionNames[ptoCheckFormatArgs], ErrorCount);
DoTestEnd(PoTestTypeNames[pttCheckFormatArgs], ErrorCount);
//debugln('TPoFamily.CheckIncompatibleFormatArgs: ',Dbgs(ErrorCount),' Errors');
end;
@ -424,7 +429,7 @@ var
MPoItem, CPoItem: TPOFileItem;
begin
//debugln('TPoFamily.CheckMissingIdentifiers');
DoTestStart(PoTestOptionNames[ptoCheckMissingIdentifiers], ShortChildName);
DoTestStart(PoTestTypeNames[pttCheckMissingIdentifiers], ShortChildName);
ErrorCount := NoError;
for i := 0 to FMaster.Count - 1 do
begin
@ -484,7 +489,7 @@ begin
ErrorLog.Add('');
ErrorLog.Add('');
end;
DoTestEnd(PoTestOptionNames[ptoCheckMissingIdentifiers], ErrorCount);
DoTestEnd(PoTestTypeNames[pttCheckMissingIdentifiers], ErrorCount);
//debugln('TPoFamily.CheckMissingIdentifiers: ',Dbgs(ErrorCount),' Errors');
end;
@ -495,7 +500,7 @@ var
MPoItem, CPoItem: TPOFileItem;
begin
//debugln('TPoFamily.CheckMismatchedOriginals');
DoTestStart(PoTestOptionNames[ptoCheckMismatchedOriginals], ShortChildName);
DoTestStart(PoTestTypeNames[pttCheckMismatchedOriginals], ShortChildName);
ErrorCount := NoError;
for i := 0 to FMaster.Count - 1 do
begin
@ -529,7 +534,7 @@ begin
ErrorLog.Add('');
ErrorLog.Add('');
end;
DoTestEnd(PoTestOptionNames[ptoCheckMismatchedOriginals], ErrorCount);
DoTestEnd(PoTestTypeNames[pttCheckMismatchedOriginals], ErrorCount);
//debugln('TPoFamily.CheckMismatchedOriginals: ',Dbgs(ErrorCount),' Errors');
end;
@ -541,7 +546,7 @@ var
LastHash, CurHash: Cardinal;
begin
//debugln('TPoFamily.CheckMismatchedOriginals');
DoTestStart(PoTestOptionNames[ptoCheckDuplicateOriginals], ShortMasterName);
DoTestStart(PoTestTypeNames[pttCheckDuplicateOriginals], ShortMasterName);
WarningCount := 0;
//debugln('TPoFamily.CehckDuplicateOriginals');
@ -586,7 +591,7 @@ begin
ErrorLog.Add('');
end;
DoTestEnd(PoTestOptionNames[ptoCheckDuplicateOriginals], WarningCount);
DoTestEnd(PoTestTypeNames[pttCheckDuplicateOriginals], WarningCount);
//debugln('TPoFamily.CheckDuplicateOriginals: ',Dbgs(WarningCount),' Errors');
end;
@ -636,18 +641,18 @@ begin
ErrorLog.Add('');
end;
WarningCount := NrTotal;
DoTestEnd(PoTestOptionNames[ptoCheckFormatArgs], WarningCount);
DoTestEnd(PoTestTypeNames[pttCheckFormatArgs], WarningCount);
//debugln('TPoFamily.CheckIncompatibleFormatArgs: ',Dbgs(ErrorCount),' Errors');
end;
{
procedure TPoFamily.RunTests(const Options: TPoTestOptions; out
procedure TPoFamily.RunTests(const Options: TPoTestTypes; out
Pre conditions:
* Master and a matching Child must be assigned at start ot testing
* If a Child is assigned it must be child of Master
}
procedure TPoFamily.RunTests(const Options: TPoTestOptions; out
ErrorCount, WarningCount: Integer; ErrorLog: TStrings);
procedure TPoFamily.RunTests(const TestTypes: TPoTestTypes; const TestOptions: TPoTestOptions;
out ErrorCount, WarningCount: Integer; ErrorLog: TStrings);
var
SL: TStringList;
CurrErrCnt, CurrWarnCnt: Integer;
@ -680,7 +685,7 @@ begin
Exit;
end
end;
if not Assigned(FChild) and ([ptoFindAllChildren, ptoCheckDuplicateOriginals] * Options = []) then
if not Assigned(FChild) and not ((pttCheckDuplicateOriginals in Testtypes) or (ptoFindAllChildren in TestOptions)) then
begin
{$ifdef DebugSimplePoFiles}
Debugln('TPoFamily.RunTests: no child assigned for ',ShortMasterName);
@ -688,7 +693,7 @@ begin
Exit;
end;
if (ptoFindAllChildren in Options) then
if (ptoFindAllChildren in TestOptions) then
begin
SL := FindAllTranslatedPoFiles(FMasterName);
//We want current Child (if currently assigned) at index 0
@ -715,7 +720,7 @@ begin
try
//First run checks that are Master-only
if (ptoCheckDuplicateOriginals in Options) then
if (pttCheckDuplicateOriginals in TestTypes) then
begin
CheckDuplicateOriginals(CurrWarnCnt, ErrorLog);
WarningCount := CurrWarnCnt + WarningCount;
@ -725,7 +730,7 @@ begin
Debugln('TPoFamily.RunTests: number of childs for testing = ',DbgS(Sl.Count));
{$endif}
if (Options - [ptoCheckDuplicateOriginals] <> []) and (Sl.Count = 0) then
if (TestTypes - [pttCheckDuplicateOriginals] <> []) and (Sl.Count = 0) then
begin
{$ifdef DebugSimplePoFiles}
Debugln('TPoFamily.RunTests: Warning: No child selected or found for selected tests');
@ -743,38 +748,38 @@ begin
//debugln('TPoFamily.RunTests: setting ChildName to ',CurrChildName);
SetChildName(CurrChildName);
if (ptoCheckNrOfItems in Options) then
if (pttCheckNrOfItems in TestTypes) then
begin
CheckNrOfItems(CurrErrCnt, ErrorLog);
ErrorCount := CurrErrCnt + ErrorCount;
end;
if (ptoCheckFormatArgs in Options) then
if (pttCheckFormatArgs in TestTypes) then
begin
CheckFormatArgs(CurrErrCnt, ErrorLog);
CheckFormatArgs(CurrErrCnt, ErrorLog, (ptoIgnoreFuzzyStrings in TestOptions));
ErrorCount := CurrErrCnt + ErrorCount;
end;
if (ptoCheckMissingIdentifiers in Options) then
if (pttCheckMissingIdentifiers in TestTypes) then
begin
CheckMissingIdentifiers(CurrErrCnt, ErrorLog);
ErrorCount := CurrErrCnt + ErrorCount;
end;
if (ptoCheckMismatchedOriginals in Options) then
if (pttCheckMismatchedOriginals in TestTypes) then
begin
CheckMismatchedOriginals(CurrErrCnt, ErrorLog);
ErrorCount := CurrErrCnt + ErrorCount;
end;
if (ptoCheckStatistics in Options) then
if (pttCheckStatistics in TestTypes) then
begin
CheckStatistics(CurrErrCnt, ErrorLog);
ErrorCount := CurrErrCnt + ErrorCount;
end;
{
if (pto in Options) then
if (ptt in TestTypes) then
begin
Check(CurrErrCnt, ErrorLog);
ErrorCount := CurrErrCnt + ErrorCount;
@ -789,10 +794,9 @@ end;
procedure InitTestOptions;
var
Index: TPoTestOption;
Index: TPoTestType;
begin
for Index := Low(TPoTestOption) to High(TPotestOption) do optRunAllTestsOnAllChildren := optRunAllTestsOnAllChildren + [Index];
optRunAllTests := optRunAllTestsOnAllChildren - [ptoFindAllChildren];
for Index := Low(TPoTestType) to High(TPoTestType) do optRunAllTests := optRunAllTests + [Index];
end;
Initialization