From 7c9f2ba5c34968863eadaea2dc09f9bf8ca63736 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Wed, 8 Oct 2014 17:44:38 +0000 Subject: [PATCH] PoChecker: refactor. - Drop the listbox for translated po-files - Now possible to test multiple master po-files - Language filter controls setting of "Find All Translated PoFiles" - Regenerated language files. git-svn-id: trunk@46475 - --- components/pochecker/Proj/pochecker.lpi | 7 +- components/pochecker/Proj/pochecker.lpr | 2 +- .../pochecker/languages/pocheckerconsts.cs.po | 18 +- .../pochecker/languages/pocheckerconsts.de.po | 23 +- .../pochecker/languages/pocheckerconsts.es.po | 18 +- .../pochecker/languages/pocheckerconsts.hu.po | 18 +- .../pochecker/languages/pocheckerconsts.it.po | 18 +- .../pochecker/languages/pocheckerconsts.ja.po | 18 +- .../pochecker/languages/pocheckerconsts.lt.po | 18 +- .../pochecker/languages/pocheckerconsts.po | 13 +- .../languages/pocheckerconsts.pt_BR.po | 18 +- .../pochecker/languages/pocheckerconsts.ru.po | 18 +- .../pochecker/languages/pocheckerconsts.uk.po | 18 +- components/pochecker/pocheckerconsts.pas | 6 +- components/pochecker/pocheckermain.lfm | 118 ++---- components/pochecker/pocheckermain.pp | 370 ++++++++---------- components/pochecker/pocheckersettings.pp | 69 ++-- components/pochecker/pofamilies.pp | 17 +- 18 files changed, 325 insertions(+), 462 deletions(-) diff --git a/components/pochecker/Proj/pochecker.lpi b/components/pochecker/Proj/pochecker.lpi index b32545b302..1baa2ca276 100644 --- a/components/pochecker/Proj/pochecker.lpi +++ b/components/pochecker/Proj/pochecker.lpi @@ -69,7 +69,7 @@ - + @@ -118,6 +118,11 @@ + + + + + diff --git a/components/pochecker/Proj/pochecker.lpr b/components/pochecker/Proj/pochecker.lpr index 13c2660546..5aac9e71bc 100644 --- a/components/pochecker/Proj/pochecker.lpr +++ b/components/pochecker/Proj/pochecker.lpr @@ -8,7 +8,7 @@ uses {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Forms, pocheckermain, pofamilies, resultdlg, simplepofiles, pocheckerconsts, - graphstat, pocheckersettings; + graphstat, pocheckersettings, pofamilylists; {$R *.res} diff --git a/components/pochecker/languages/pocheckerconsts.cs.po b/components/pochecker/languages/pocheckerconsts.cs.po index f832ff029c..49075f8cbf 100644 --- a/components/pochecker/languages/pocheckerconsts.cs.po +++ b/components/pochecker/languages/pocheckerconsts.cs.po @@ -99,9 +99,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Chyby / varování nahlášené %s pro:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Najít všechny přeložené po soubory" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -144,15 +146,9 @@ msgstr "Identifikátor [%s] nalezen v %s, ale neexistuje v %s" msgid "No errors found" msgstr "Žádné chyby nenalezeny" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Vybraný název souboru\n" -"%s\n" -"nevypadá jako korektní jméno po souboru\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.de.po b/components/pochecker/languages/pocheckerconsts.de.po index 9d37460158..d565787066 100644 --- a/components/pochecker/languages/pocheckerconsts.de.po +++ b/components/pochecker/languages/pocheckerconsts.de.po @@ -72,8 +72,7 @@ msgstr "[Zeile %d] %s" #: pocheckerconsts.sduplicateoriginals msgid "The (untranslated) value \"%s\" is used for more than 1 entry:" -msgstr "" -"Der (nicht übersetzte) Wert \"%s\" wird für mehr als 1 Eintrag verwendet:" +msgstr "Der (nicht übersetzte) Wert \"%s\" wird für mehr als 1 Eintrag verwendet:" #: pocheckerconsts.serroroncleanup msgid "" @@ -97,9 +96,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Fehler / Warnungen gemeldet von %s für:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Alle übersetzten po-Dateien finden" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -141,16 +142,9 @@ msgstr "Bezeichner [%s] gefunden in %s, aber er existiert nicht in %s" msgid "No errors found" msgstr "Keine Fehler gefunden" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Gewählter Dateiname\n" -"%s\n" -"sieht nicht wie ein geeigneter Name für eine po-file\n" -" aus\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." @@ -325,3 +319,4 @@ msgstr "Abwählen" #: pocheckerconsts.suntranslated msgid "Untranslated" msgstr "Nicht übersetzt" + diff --git a/components/pochecker/languages/pocheckerconsts.es.po b/components/pochecker/languages/pocheckerconsts.es.po index 4df8a9d4e1..a26221fd30 100644 --- a/components/pochecker/languages/pocheckerconsts.es.po +++ b/components/pochecker/languages/pocheckerconsts.es.po @@ -95,9 +95,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Errores / advertencias reportadas por %s para:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Encontrar todos los archivos PO traducidos" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -141,15 +143,9 @@ msgstr "Identificador [%s] se encuentra en %s, pero no existe en %s" msgid "No errors found" msgstr "No se encontraron errores" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Seleccionado archivo\n" -"%s\n" -"no parece ser un nombre apropiado para un archivo po\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.hu.po b/components/pochecker/languages/pocheckerconsts.hu.po index 1a26ef3e18..3725303098 100644 --- a/components/pochecker/languages/pocheckerconsts.hu.po +++ b/components/pochecker/languages/pocheckerconsts.hu.po @@ -97,9 +97,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "A(z) %s hibákat / figyelmeztetéseket jelzett ezzel kapcsolatban:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Az összes lefordított po-fájl megkeresése" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -141,15 +143,9 @@ msgstr "A(z) [%s] azonosító megtalálható itt: %s, de nem található meg itt msgid "No errors found" msgstr "Nincsenek hibák" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"A választott fájlnév\n" -"%s\n" -"nem tűnik megfelelő névnek egy po-fájl számára\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.it.po b/components/pochecker/languages/pocheckerconsts.it.po index bc43dd3a0e..08e5b2807c 100644 --- a/components/pochecker/languages/pocheckerconsts.it.po +++ b/components/pochecker/languages/pocheckerconsts.it.po @@ -97,9 +97,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Errori / avvertimenti riportati da %s per:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Trova tutti i file po tradotti" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -141,15 +143,9 @@ msgstr "Identificatore [%s] trovato in %s, ma inesistente in %s" msgid "No errors found" msgstr "Nessun errore riscontrato" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Il nome selezionato\n" -"%s\n" -"non sembra un nome corretto per un file po\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.ja.po b/components/pochecker/languages/pocheckerconsts.ja.po index e694c55489..8937f987b0 100644 --- a/components/pochecker/languages/pocheckerconsts.ja.po +++ b/components/pochecker/languages/pocheckerconsts.ja.po @@ -97,9 +97,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "以下のファイルに対する %s によるエラー/警告の結果:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "翻訳されたすべての po ファイルを検査する" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -141,15 +143,9 @@ msgstr "識別子 [%s] が %s 内で見つかりましたが、%s 内には存 msgid "No errors found" msgstr "エラーはありません" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"選択されたファイル\n" -"%s\n" -"は、適切な po ファイル名ではないようです\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.lt.po b/components/pochecker/languages/pocheckerconsts.lt.po index 18380d553c..f535cfc0c6 100644 --- a/components/pochecker/languages/pocheckerconsts.lt.po +++ b/components/pochecker/languages/pocheckerconsts.lt.po @@ -97,9 +97,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "%s praneštos klaidos/perspėjimai apie:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Rasti visus išverstus PO failus" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -143,15 +145,9 @@ msgstr "Identifikatorių [%s] turi „%s“, tačiau jo neturi „%s“" msgid "No errors found" msgstr "Klaidų nerasta" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Parinktas failo pavadinimas\n" -"%s\n" -"nepanašu kad tai būtų tinkamas pavadinimas PO failui\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.po b/components/pochecker/languages/pocheckerconsts.po index 6348d9e9bc..200e451475 100644 --- a/components/pochecker/languages/pocheckerconsts.po +++ b/components/pochecker/languages/pocheckerconsts.po @@ -78,8 +78,10 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" msgstr "" #: pocheckerconsts.sfuzzy @@ -122,11 +124,8 @@ msgstr "" msgid "No errors found" msgstr "" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" #: pocheckerconsts.snotestselected diff --git a/components/pochecker/languages/pocheckerconsts.pt_BR.po b/components/pochecker/languages/pocheckerconsts.pt_BR.po index 7cd4a7f919..3b5e19b13a 100644 --- a/components/pochecker/languages/pocheckerconsts.pt_BR.po +++ b/components/pochecker/languages/pocheckerconsts.pt_BR.po @@ -96,9 +96,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Erros / avisos reportados por %s para:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Localizar todos os arquivos po traduzidos" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -141,15 +143,9 @@ msgstr "Identificador [%s] encontrado em %s, mas inexistente em %s" msgid "No errors found" msgstr "Nenhum erro encontrado" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Nome de arquivo selecionado\n" -"%s\n" -"parece não ser um nome apropriado para um arquivo PO\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.ru.po b/components/pochecker/languages/pocheckerconsts.ru.po index a664a35410..85440faa3e 100644 --- a/components/pochecker/languages/pocheckerconsts.ru.po +++ b/components/pochecker/languages/pocheckerconsts.ru.po @@ -95,9 +95,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Ошибки и предупреждения, найденные %s для:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Найти все переведённые файлы PO" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -140,15 +142,9 @@ msgstr "Идентификатор [%s] найден в %s, но отсутст msgid "No errors found" msgstr "Ошибок не найдено" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Выбранное имя файла\n" -"%s\n" -"не выглядит корректно для файла PO\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/languages/pocheckerconsts.uk.po b/components/pochecker/languages/pocheckerconsts.uk.po index e1fc9e88aa..6284250669 100644 --- a/components/pochecker/languages/pocheckerconsts.uk.po +++ b/components/pochecker/languages/pocheckerconsts.uk.po @@ -94,9 +94,11 @@ msgstr "" msgid "Errors / warnings reported by %s for:" msgstr "Помилки / попередження звітовані %s для:" -#: pocheckerconsts.sfindalltranslatedpofiles -msgid "Find all translated po-files" -msgstr "Знайти всі перекладені po-файли" +#: pocheckerconsts.sfilesnotfoundandremoved +msgid "" +"The follwing files were not foud and removed from the list:\n" +"%s\n" +msgstr "" #: pocheckerconsts.sfuzzy msgid "Fuzzy" @@ -140,15 +142,9 @@ msgstr "Ідентифікатор [%s] знайдений в %s, але він msgid "No errors found" msgstr "Помилки не знайдені" -#: pocheckerconsts.snotaproperfilename -msgid "" -"Selected filename\n" -"%s\n" -"does not seem to be a proper name for a po-file\n" +#: pocheckerconsts.snofileslefttocheck +msgid "There are no files left to check." msgstr "" -"Вибраний файл\n" -"%s\n" -"схоже не є вірним іменем для po-файлу\n" #: pocheckerconsts.snotestselected msgid "There are no tests selected." diff --git a/components/pochecker/pocheckerconsts.pas b/components/pochecker/pocheckerconsts.pas index 8dcc512851..3c2b3aa394 100644 --- a/components/pochecker/pocheckerconsts.pas +++ b/components/pochecker/pocheckerconsts.pas @@ -21,7 +21,9 @@ resourcestring sUnselectListBox = 'Unselect'; sAllLanguages = 'All Languages'; sCannotFindMaster = 'Cannot find master po file:' + LineEnding + '%s' + LineEnding + 'for selected file' + LineEnding + '%s'; - sNotAProperFileName = 'Selected filename' + LineEnding + '%s' + LineEnding + 'does not seem to be a proper name for a po-file'; + //sNotAProperFileName = 'Selected filename' + LineEnding + '%s' + LineEnding + 'does not seem to be a proper name for a po-file'; + sFilesNotFoundAndRemoved = 'The follwing files were not foud and removed from the list:' + LineEnding + '%s'; + sNoFilesLeftToCheck = 'There are no files left to check.'; sErrorOnCreate = 'Error creating an instance of TPoFamily:' + LineEnding + '%s'; sErrorOnCleanup = 'An unrecoverable error occurred' + LineEnding + '%s' + LineEnding + 'Please close the program'; @@ -69,7 +71,7 @@ resourcestring sCheckForDuplicateUntranslatedValues = 'Check for duplicate untranslated ' +'values'; sCheckStatistics = 'Check percentage of (un)translated and fuzzy strings'; - sFindAllTranslatedPoFiles = 'Find all translated po-files'; + //sFindAllTranslatedPoFiles = 'Find all translated po-files'; sIgnoreFuzzyTranslations = 'Ignore translated strings marked as "fuzzy"'; sIncompatibleFormatArgs = '[Line: %d] Incompatible and/or invalid format() arguments for:' ; diff --git a/components/pochecker/pocheckermain.lfm b/components/pochecker/pocheckermain.lfm index 153b8907c4..d2f2bcb716 100644 --- a/components/pochecker/pocheckermain.lfm +++ b/components/pochecker/pocheckermain.lfm @@ -1,11 +1,11 @@ object PoCheckerForm: TPoCheckerForm Left = 318 - Height = 514 + Height = 513 Top = 163 Width = 644 Anchors = [] Caption = 'GUI Po-file checking tool' - ClientHeight = 514 + ClientHeight = 513 ClientWidth = 644 Constraints.MinHeight = 450 Constraints.MinWidth = 600 @@ -123,7 +123,7 @@ object PoCheckerForm: TPoCheckerForm object NoErrLabel: TLabel Left = 8 Height = 25 - Top = 452 + Top = 451 Width = 146 Anchors = [akLeft, akBottom] Caption = 'No errors found' @@ -133,18 +133,6 @@ object PoCheckerForm: TPoCheckerForm ParentColor = False ParentFont = False end - object FindAllPOsCheckBox: TCheckBox - AnchorSideLeft.Control = TestListBox - AnchorSideTop.Control = SelectBasicBtn - AnchorSideTop.Side = asrBottom - Left = 201 - Height = 19 - Top = 184 - Width = 156 - BorderSpacing.Top = 6 - Caption = 'Find all translated PO files' - TabOrder = 3 - end object SelectBasicBtn: TButton AnchorSideLeft.Control = TestListBox AnchorSideTop.Control = TestListBox @@ -157,7 +145,7 @@ object PoCheckerForm: TPoCheckerForm Caption = 'Select Basic Tests' Enabled = False OnClick = SelectBasicBtnClick - TabOrder = 4 + TabOrder = 3 end object SelectAllBtn: TButton AnchorSideLeft.Control = SelectBasicBtn @@ -171,7 +159,7 @@ object PoCheckerForm: TPoCheckerForm Caption = 'Select All Tests' Enabled = False OnClick = SelectAllBtnClick - TabOrder = 5 + TabOrder = 4 end object UnselectAllBtn: TButton AnchorSideLeft.Control = SelectAllBtn @@ -185,24 +173,24 @@ object PoCheckerForm: TPoCheckerForm Caption = 'Unselect All Tests' Enabled = False OnClick = UnselectAllBtnClick - TabOrder = 6 + TabOrder = 5 end object IgnoreFuzzyCheckBox: TCheckBox AnchorSideLeft.Control = TestListBox - AnchorSideTop.Control = FindAllPOsCheckBox + AnchorSideTop.Control = SelectBasicBtn AnchorSideTop.Side = asrBottom Left = 201 Height = 19 - Top = 209 + Top = 184 Width = 152 BorderSpacing.Top = 6 Caption = 'sIgnoreFuzzyTranslations' - TabOrder = 7 + TabOrder = 6 end object StatusBar: TStatusBar Left = 0 Height = 23 - Top = 491 + Top = 490 Width = 644 Panels = <> end @@ -257,58 +245,39 @@ object PoCheckerForm: TPoCheckerForm FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00 } OnClick = ScanDirBtnClick - TabOrder = 9 + TabOrder = 8 end object MasterPoListBox: TListBox AnchorSideTop.Control = IgnoreFuzzyCheckBox AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = TestListBox + AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = NoErrLabel Left = 8 - Height = 184 - Top = 233 - Width = 272 - Anchors = [akTop, akLeft, akBottom] + Height = 185 + Top = 208 + Width = 629 + Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Top = 5 - BorderSpacing.Bottom = 35 + BorderSpacing.Bottom = 58 ItemHeight = 0 + MultiSelect = True OnDrawItem = MasterPoListBoxDrawItem + OnResize = MasterPoListBoxResize OnSelectionChange = MasterPoListBoxSelectionChange Sorted = True Style = lbOwnerDrawFixed - TabOrder = 10 - end - object ChildPoListBox: TListBox - AnchorSideLeft.Control = MasterPoListBox - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = MasterPoListBox - AnchorSideRight.Control = TestListBox - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = ClearChildBtn - Left = 290 - Height = 154 - Top = 233 - Width = 347 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 10 - BorderSpacing.Bottom = 40 - ItemHeight = 0 - OnDrawItem = MasterPoListBoxDrawItem - OnResize = ChildPoListBoxResize - OnSelectionChange = ChildPoListBoxSelectionChange - Style = lbOwnerDrawFixed - TabOrder = 11 + TabOrder = 9 end object LangFilter: TComboBox - AnchorSideLeft.Control = ChildPoListBox - AnchorSideTop.Control = ChildPoListBox + AnchorSideLeft.Control = MasterPoListBox AnchorSideTop.Side = asrBottom AnchorSideRight.Control = TestListBox AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = ClearChildBtn - Left = 290 + Left = 8 Height = 23 - Top = 396 - Width = 347 + Top = 400 + Width = 629 Anchors = [akLeft, akRight] BorderSpacing.Top = 5 ItemHeight = 15 @@ -340,7 +309,7 @@ object PoCheckerForm: TPoCheckerForm ) OnChange = LangFilterChange Style = csDropDownList - TabOrder = 12 + TabOrder = 10 Text = 'All languages' end object ClearMasterBtn: TButton @@ -350,13 +319,13 @@ object PoCheckerForm: TPoCheckerForm AnchorSideBottom.Control = NoErrLabel Left = 8 Height = 25 - Top = 427 + Top = 426 Width = 75 Anchors = [akLeft, akBottom] BorderSpacing.Top = 10 Caption = 'Clear' OnClick = ClearMasterBtnClick - TabOrder = 13 + TabOrder = 11 end object UnselectMasterBtn: TButton AnchorSideLeft.Control = ClearMasterBtn @@ -364,41 +333,14 @@ object PoCheckerForm: TPoCheckerForm AnchorSideBottom.Control = NoErrLabel Left = 93 Height = 25 - Top = 427 + Top = 426 Width = 75 Anchors = [akLeft, akBottom] BorderSpacing.Left = 10 Caption = 'Unselect' Enabled = False OnClick = UnselectMasterBtnClick - TabOrder = 14 - end - object ClearChildBtn: TButton - AnchorSideLeft.Control = ChildPoListBox - AnchorSideBottom.Control = NoErrLabel - Left = 290 - Height = 25 - Top = 427 - Width = 75 - Anchors = [akLeft, akBottom] - Caption = 'Clear' - OnClick = ClearChildBtnClick - TabOrder = 15 - end - object UnselectChildBtn: TButton - AnchorSideLeft.Control = ClearChildBtn - AnchorSideLeft.Side = asrBottom - AnchorSideBottom.Control = NoErrLabel - Left = 375 - Height = 25 - Top = 427 - Width = 75 - Anchors = [akLeft, akBottom] - BorderSpacing.Left = 10 - Caption = 'Unselect' - Enabled = False - OnClick = UnselectChildBtnClick - TabOrder = 16 + TabOrder = 12 end object OpenDialog: TOpenDialog Filter = 'po-files (*.po)|*.po|all files|*' diff --git a/components/pochecker/pocheckermain.pp b/components/pochecker/pocheckermain.pp index ad9e2a3097..40a09b54e7 100644 --- a/components/pochecker/pocheckermain.pp +++ b/components/pochecker/pocheckermain.pp @@ -25,14 +25,15 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, - StdCtrls, LCLProc, CheckLst, Buttons, ExtCtrls, ComCtrls, Masks, Types, + StdCtrls, LCLProc, CheckLst, Buttons, ExtCtrls, ComCtrls, Types, LCLType, {$IFDEF POCHECKERSTANDALONE} Translations, {$ELSE} IDEIntf, MenuIntf, {$ENDIF} - SimplePoFiles, PoFamilies, ResultDlg, pocheckerconsts, PoCheckerSettings; + SimplePoFiles, PoFamilies, ResultDlg, pocheckerconsts, PoCheckerSettings, + PoFamilyLists; type @@ -40,18 +41,13 @@ type TPoCheckerForm = class(TForm) SelectDirectoryDialog: TSelectDirectoryDialog; - UnselectChildBtn: TButton; - ClearChildBtn: TButton; UnselectMasterBtn: TButton; ClearMasterBtn: TButton; LangFilter: TComboBox; - ChildPoListBox: TListBox; MasterPoListBox: TListBox; ScanDirBtn: TBitBtn; StatusBar: TStatusBar; - procedure ChildPoListBoxResize(Sender: TObject); - procedure ChildPoListBoxSelectionChange(Sender: TObject; User: boolean); - procedure ClearChildBtnClick(Sender: TObject); + procedure MasterPoListBoxResize(Sender: TObject); procedure ClearMasterBtnClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure LangFilterChange(Sender: TObject); @@ -62,10 +58,9 @@ type procedure UnselectChildBtnClick(Sender: TObject); procedure UnselectMasterBtnClick(Sender: TObject); private - PoFamily: TPoFamily; - FSelectedPoName: String; + //PoFamily: TPoFamily; + PoFamilyList: TPoFamilyList; FPoCheckerSettings: TPoCheckerSettings; - FChildPoList: TStringList; procedure OnTestStart(const ATestName, APoFileName: string); procedure OnTestEnd(const {%H-}ATestName: string; const {%H-}ErrorCount: integer); procedure FillTestListBox; @@ -76,14 +71,14 @@ type procedure ShowError(const Msg: string); function TrySelectFile(out Filename: String): Boolean; procedure ScanDirectory(ADir: String); - function TryCreatePoFamily(Filename: String): Boolean; + function TryCreatepoFamilyList(MasterList: TStrings; const Lang: String): Boolean; procedure RunSelectedTests; procedure ClearStatusBar; - procedure SetSelectedPoName(AFilename: String); + procedure UpdateGUI(HasSelection: Boolean); + function GetSelectedMasterFiles: TStringList; procedure AddToMasterPoList(Fn: String); procedure AddToMasterPoList(S: TStrings); - procedure AddToChildPoList(Fn: String); - procedure AddToChildPoList(S: TStrings); + procedure SetSelectedMasterFiles(S: TStrings); procedure LoadConfig; procedure SaveConfig; published @@ -91,7 +86,6 @@ type UnselectAllBtn: TButton; SelectAllBtn: TButton; SelectBasicBtn: TButton; - FindAllPOsCheckBox: TCheckBox; NoErrLabel: TLabel; RunBtn: TBitBtn; OpenBtn: TBitBtn; @@ -152,20 +146,15 @@ begin 'lclstrconsts.' + Lang + '.po'); end; {$ENDIF} - FChildPoList := TStringList.Create; - FChildPoList.Sorted := True; - FChildPoList.Duplicates := dupIgnore; Caption := sGUIPoFileCheckingTool; SelectTestLabel.Caption := sSelectTestTypes; - FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles; + //FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles; IgnoreFuzzyCheckBox.Caption := sIgnoreFuzzyTranslations; OpenBtn.Caption := sOpenAPoFile; ScanDirBtn.Caption := sScanDir; RunBtn.Caption := sRunSelectedTests; ClearMasterBtn.Caption := sClearListBox; - ClearChildBtn.Caption := sClearListBox; UnselectMasterBtn.Caption := sUnselectListBox; - UnselectChildBtn.Caption := sUnselectListBox; LangFilter.Items[0] := sAllLanguages; NoErrLabel.Caption := sNoErrorsFound; FillTestListBox; @@ -181,12 +170,11 @@ end; procedure TPoCheckerForm.FormDestroy(Sender: TObject); begin - if Assigned(PoFamily) then - PoFamily.Free; + if Assigned(PoFamilyList) then + PoFamilyList.Free; SaveConfig; if Assigned(FPoCheckerSettings) then FPoCheckerSettings.Free; - FChildPoList.Free; end; @@ -199,23 +187,38 @@ begin if IsMasterPoName(Fn) then AddToMasterPoList(Fn) else - AddToChildPoList(Fn); - SetSelectedPoName(Fn); + //AddToChildPoList(Fn); + AddToMasterPoList(ExtractMasterNameFromChildName(Fn)); + UpdateGUI(True); end else begin - SetSelectedPoName(''); + UpdateGUI(False); end; end; procedure TPoCheckerForm.RunBtnClick(Sender: TObject); +var + AMasterList: TStringList; + LangIdx: Integer; + ALang: String; begin - if TryCreatePoFamily(FSelectedPoName) then - RunSelectedTests + LangIdx := LangFilter.ItemIndex; + if (LangIdx > 0) then + ALang := LangFilter.Items[LangIdx] else - begin - if Assigned(PoFamily) then FreeAndNil(PoFamily); + ALang := langAll; + AMasterList := GetSelectedMasterFiles; + try + if TryCreatePoFamilyList(AMasterList, ALang) then + RunSelectedTests + else + begin + if Assigned(PoFamilyList) then FreeAndNil(PoFamilyList); + end; + finally + AMasterList.Free; end; end; @@ -240,85 +243,24 @@ begin end; procedure TPoCheckerForm.LangFilterChange(Sender: TObject); -var - Filter, Mask, PrevItem: String; - Idx, i: Integer; begin - Idx := ChildPoListBox.ItemIndex; - if (Idx > -1) then - PrevItem := ChildPoListBox.Items[Idx] - else - PrevItem := ''; - //debugln('TPoCheckerForm.LangFilterChange: PrevItem = "',PrevItem,'"'); - Filter := LangFilter.Items.Strings[LangFilter.ItemIndex]; - if (LangFilter.ItemIndex > 0) then - begin - Mask := '*.'+Filter+'.po'; - ChildPoListBox.Clear; - ChildPoListBox.Items.BeginUpdate; - try - for i := 0 to FChildPoList.Count - 1 do - begin - if MatchesMask(FChildPoList.Strings[i], Mask, False) then - ChildPoListBox.Items.Add(FChildPoList.Strings[i]); - end; - finally - ChildPoListBox.Items.EndUpdate; - end; - end - else - ChildPoListBox.Items.Assign(FChildPoList); - if (Idx <> -1) then - begin - Idx := ChildPoListBox.Items.IndexOf(PrevItem); - debugln('TPoCheckerForm.LangFilterChange: IndexOf(PrevItem) = ',DbgS(Idx)); - if (Idx <> -1) then - begin - ChildPoListBox.ItemIndex := Idx; - end - else - begin - if (MasterPoListBox.ItemIndex = -1) then - SetSelectedPoName(''); - end; - end; - UnselectChildBtn.Enabled := (Idx <> -1); end; -procedure TPoCheckerForm.ChildPoListBoxSelectionChange(Sender: TObject; - User: boolean); -begin - //debugln('TPoCheckerForm.ChildPoListBoxSelectionChange: User = ',DbgS(User)); - if User then - begin - SetSelectedPoName(ChildPoListBox.Items[ChildPoListBox.ItemIndex]); - end; - UnselectChildBtn.Enabled := (ChildPoListBox.ItemIndex <> -1); -end; -procedure TPoCheckerForm.ChildPoListBoxResize(Sender: TObject); +procedure TPoCheckerForm.MasterPoListBoxResize(Sender: TObject); var - ATop, ADiff: Integer; + ATop: Integer; begin //Can't seem to get this to work with just Anchors - ATop := ChildPoListBox.Top + ChildPoListBox.Height; - ADiff := MasterPoListBox.Top + MasterPoListBox.Height - ATop; - LangFilter.Top := ATop + (ADiff - LangFilter.Height); + ATop := MasterPoListBox.Top + MasterPoListBox.Height; + LangFilter.Top := ATop + 5; end; -procedure TPoCheckerForm.ClearChildBtnClick(Sender: TObject); -begin - FChildPoList.Clear; - LangFilterChange(LangFilter); - if (MasterPoListBox.ItemIndex = -1) then - SetSelectedPoName(''); -end; procedure TPoCheckerForm.ClearMasterBtnClick(Sender: TObject); begin MasterPoListBox.Clear; - if (ChildPoListBox.ItemIndex = -1) then - SetSelectedPoName(''); + UpdateGUI(False); end; procedure TPoCheckerForm.FormShow(Sender: TObject); @@ -353,9 +295,9 @@ begin //debugln('TPoCheckerForm.MasterPoListBoxSelectionChange: User = ',DbgS(User)); if User then begin - SetSelectedPoName(MasterPoListBox.Items[MasterPoListBox.ItemIndex]); + UpdateGUI(MasterPoListBox.SelCount > 0); end; - UnselectMasterBtn.Enabled := (MasterPoListBox.ItemIndex <> -1); + UnselectMasterBtn.Enabled := (MasterPoListBox.SelCount <> 0); end; procedure TPoCheckerForm.ScanDirBtnClick(Sender: TObject); @@ -368,16 +310,12 @@ end; procedure TPoCheckerForm.UnselectChildBtnClick(Sender: TObject); begin - ChildpoListBox.ItemIndex := -1; - if (MasterPoListBox.ItemIndex = -1) then - SetSelectedPoName(''); end; procedure TPoCheckerForm.UnselectMasterBtnClick(Sender: TObject); begin - MasterPoListBox.ItemIndex := -1; - if (ChildPoListBox.ItemIndex = -1) then - SetSelectedPoName(''); + MasterPoListBox.ClearSelection; + UpdateGUI(False); end; procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: string); @@ -443,8 +381,8 @@ end; function TPoCheckerForm.GetTestOptions: TPoTestOptions; begin Result := []; - if FindAllPOsCheckBox.Checked then - Result := Result + [ptoFindAllChildren]; + //if FindAllPOsCheckBox.Checked then + // Result := Result + [ptoFindAllChildren]; if IgnoreFuzzyCheckBox.Checked then Result := Result + [ptoIgnoreFuzzyStrings]; end; @@ -466,7 +404,7 @@ end; procedure TPoCheckerForm.SetTestOptionCheckBoxes(TestOptions: TPoTestOptions); begin - FindAllPOsCheckBox.Checked := (ptoFindAllChildren in TestOptions); + //FindAllPOsCheckBox.Checked := (ptoFindAllChildren in TestOptions); IgnoreFuzzyCheckBox.Checked := (ptoIgnoreFuzzyStrings in TestOptions); end; @@ -491,85 +429,82 @@ end; procedure TPoCheckerForm.ScanDirectory(ADir: String); var - SL, ML, CL: TStringList; + SL, ML: TStringList; i: Integer; S: String; begin SL := FindAllFiles(ADir, '*.po',True); try ML := TStringList.Create; - CL := TStringList.Create; for i := 0 to SL.Count - 1 do begin S := SL[i]; //debugln('TPoCheckerForm.ScanDirectory: S = "',ExtractFilename(S),'"'); if IsMasterPoName(S) then - ML.Add(S) - else - CL.Add(S); + ML.Add(S); end; if (ML.Count > 0) then AddToMasterPoList(ML); - if (CL.Count > 0) then AddToChildPoList(CL); finally SL.Free; ML.Free; - CL.Free; end; end; -function TPoCheckerForm.TryCreatePoFamily(Filename: String): Boolean; + +function TPoCheckerForm.TryCreatepoFamilyList(MasterList: TStrings; const Lang: String): Boolean; var - ChosenMasterName, ChosenChildName, ShortFn: String; + Fn, Msg: String; + i, Cnt: Integer; begin Result := False; - ShortFn := ExtractFileName(Filename); - if IsMasterPoName(Filename) then + Msg := ''; + Cnt := MasterList.Count; + for i := Cnt - 1 downto 0 do begin - ChosenMasterName := Filename; - ChosenChildName := ''; - end - else - begin //not a mastername, may be a child - ChosenChildName := Filename; - ChosenMasterName := ExtractMasterNameFromChildName(Filename); - if (ChosenMasterName = '') then + Fn := MasterList.Strings[i]; + if not FileExistsUtf8(Fn) then begin - ChosenMasterName := ''; - ChosenChildName := ''; - ShowError(Format(sNotAProperFileName, [ShortFn])); - end - else - if not FileExistsUtf8(ChosenMasterName) then - begin - ShowError(Format(sCannotFindMaster, - [ExtractFileName(ChosenMasterName), ShortFn])); - ChosenMasterName := ''; - ChosenChildName := ''; + MasterList.Delete(i); + Msg := Format('"%s"',[Fn]) + LineEnding + Msg; end; end; - Result := (ChosenMasterName <> ''); - if Result then + if (Msg <> '') then + MessageDlg('PoChecker',Format(sFilesNotFoundAndRemoved,[Msg]), mtInformation, [mbOk], 0); + Cnt := MasterList.Count; + if (Cnt = 0) then begin - if Assigned(PoFamily) then - PoFamily.Free; - try - PoFamily := TPoFamily.Create(ChosenMasterName, ChosenChildName); - PoFamily.OnTestStart := @OnTestStart; - PoFamily.OnTestEnd := @OnTestEnd; - except - on E: Exception do + MessageDlg('PoChecker', sNoFilesLeftToCheck, mtInformation, [mbOk], 0); + Exit; + end; + try + if Assigned(PoFamilyList) then PoFamilyList.Free; + PoFamilyList := TPoFamilyList.Create(MasterList, Lang, Msg); + if (Msg <> '') then + begin + MessageDlg('PoChecker',Format(sFilesNotFoundAndRemoved,[Msg]), mtInformation, [mbOk], 0); + if (PoFamilyList.Count = 0) then begin - Result := False; - ShowError(Format(sErrorOnCreate, [E.Message])); - if Assigned(PoFamily) then - begin - try - PoFamily.Free; - except - on E: Exception do - begin - ShowError(Format(sErrorOnCleanUp, [E.Message])); - end; + MessageDlg('PoChecker', sNoFilesLeftToCheck, mtInformation, [mbOk], 0); + FreeAndNil(PoFamilyList); + Exit; + end; + end; + PoFamilyList.OnTestStart := @OnTestStart; + PoFamilyList.OnTestEnd := @OnTestEnd; + Result := True; + except + on E: Exception do + begin + Result := False; + ShowError(Format(sErrorOnCreate, [E.Message])); + if Assigned(PoFamilyList) then + begin + try + FreeAndNil(PoFamilyList); + except + on E: Exception do + begin + ShowError(Format(sErrorOnCleanUp, [E.Message])); end; end; end; @@ -599,10 +534,8 @@ begin SL := TStringList.Create; mr := mrNone; try - if (not (ptoFindAllChildren in TestOptions)) and Assigned(PoFamily.Child) and - (PoFamily.ChildName <> FSelectedPoName) then - PoFamily.ChildName := FSelectedPoName; - PoFamily.RunTests(TestTypes, TestOptions, ErrorCount, WarningCount, SL); + + PoFamilyList.RunTests(TestTypes, TestOptions, ErrorCount, WarningCount, SL); //debugln('RunSelectedTests: ', Format(sTotalErrors, [ErrorCount])); //debugln(' ', Format(sTotalWarnings, [WarningCount])); if (ErrorCount > 0) or (WarningCount > 0) or @@ -615,7 +548,7 @@ begin ResultDlg.Log.Assign(SL); FreeAndNil(SL); //No need to keep 2 copies of this data if (pttCheckStatistics in TestTypes) then - ResultDlg.PoFamilyStats := PoFamily.PoFamilyStats + ResultDlg.PoFamilyStats := PoFamilyList.PoFamilyStats else ResultDlg.PoFamilyStats := nil; ResultDlg.Settings := FPoCheckerSettings; @@ -639,35 +572,17 @@ begin StatusBar.SimpleText := ''; end; -procedure TPoCheckerForm.SetSelectedPoName(AFilename: String); -var - Idx: Integer; +procedure TPoCheckerForm.UpdateGUI(HasSelection: Boolean); begin - //debugln('TPoCheckerForm.SetSelectedPoName: ((FSelectedPoName = AFilename)) = ',DbgS((FSelectedPoName = AFilename))); NoErrLabel.Visible := False; - //if (FSelectedPoName = AFilename) then Exit; - FSelectedPoName := AFilename; - if (AFilename <> '') then + if HasSelection then begin RunBtn.Enabled := True; TestListBox.Enabled := True; SelectAllBtn.Enabled := True; SelectBasicBtn.Enabled := True; UnselectAllBtn.Enabled := True; - Caption := sGUIPoFileCheckingTool + ' [' + ExtractFileName(AFilename) + ']'; - OpenDialog.InitialDir:= ExtractFileDir(AFilename); - if IsMasterPoName(AFilename) then - begin - Idx := MasterPoListBox.Items.IndexOf(AFilename); - MasterPoListBox.ItemIndex := Idx; - ChildPoListBox.ItemIndex := -1; - end - else - begin - Idx := ChildPoListBox.Items.IndexOf(AFilename); - ChildPoListBox.ItemIndex := Idx; - MasterPoListBox.ItemIndex := -1; - end; + UnselectMasterBtn.Enabled := True; end else begin @@ -676,9 +591,21 @@ begin SelectAllBtn.Enabled := False; SelectBasicBtn.Enabled := False; UnselectAllBtn.Enabled := False; - Caption := sGUIPoFileCheckingTool; - ChildPoListBox.ItemIndex := -1; - MasterPoListBox.ItemIndex := -1; + UnselectMasterBtn.Enabled := False; + end; +end; + +function TPoCheckerForm.GetSelectedMasterFiles: TStringList; +var + i: Integer; + Fn: String; +begin + Result := TStringList.Create; + for i := 0 to MasterPoListBox.Items.Count - 1 do + begin + Fn := MasterpoListBox.Items[i]; + if MasterPoListBox.Selected[i] then + Result.Add(Fn); end; end; @@ -686,6 +613,7 @@ procedure TPoCheckerForm.AddToMasterPoList(Fn: String); var Idx: Integer; begin + if not FileExistsUtf8(Fn) then Exit; Idx := MasterPoListBox.Items.IndexOf(Fn); if (Idx = -1) then begin @@ -696,54 +624,59 @@ end; procedure TPoCheckerForm.AddToMasterPoList(S: TStrings); var i, Idx: Integer; - Str, PrevItem: String; + Str: String; begin + { Idx := MasterPoListBox.ItemIndex; if (Idx <> -1) then PrevItem := MasterPoListBox.Items[Idx] else PrevItem := ''; + } MasterPoListBox.Items.BeginUpdate; try for i := 0 to S.Count - 1 do begin Str := S[i]; - Idx := MasterPoListBox.Items.IndexOf(Str); - if (Idx = -1) then - MasterPoListBox.Items.Add(Str); + //skip files that do not exist (anymore) + if FileExistsUtf8(Str) then + begin + Idx := MasterPoListBox.Items.IndexOf(Str); + if (Idx = -1) then + MasterPoListBox.Items.Add(Str); + end end; + { if (PrevItem <> '') then begin Idx := MasterPoListBox.Items.IndexOf(PrevItem); MasterPoListBox.ItemIndex := Idx; end; + } finally MasterPoListBox.Items.EndUpdate; end; end; -procedure TPoCheckerForm.AddToChildPoList(Fn: String); -var - Idx: Integer; -begin - Idx := FChildPoList.Add(Fn); - if (Idx > -1) then - LangFilterChange(LangFilter); -end; - -procedure TPoCheckerForm.AddToChildPoList(S: TStrings); +procedure TPoCheckerForm.SetSelectedMasterFiles(S: TStrings); var i, Idx: Integer; - Str: String; + Fn: String; + HasSelection: Boolean; begin + MasterPoListBox.ClearSelection; for i := 0 to S.Count - 1 do begin - Str := S[i]; - Idx := FChildPoList.IndexOf(Str); - if (Idx = -1) then - FChildPoList.Add(Str); + Fn := S.Strings[i]; + Idx := MasterPoListBox.Items.IndexOf(Fn); + if (Idx <> -1) then + begin + MasterPoListBox.Selected[Idx] := True; + HasSelection := True; + end; end; - LangFilterChange(LangFilter); + //debugln('TPoCheckerForm.SetSelectedMasterFiles: MasterPoListBox.SelCount = ',DbgS(MasterPoListBox.SelCount)); + UpdateGUI(HasSelection); end; @@ -764,22 +697,26 @@ begin SelectDirectoryDialog.Filename := FPoCheckerSettings.SelectDirectoryFilename; OpenDialog.FileName := FPoCheckerSettings.OpenDialogFilename; AddToMasterPoList(FPoCheckerSettings.MasterPoList); - AddToChildPoList(FPoCheckerSettings.ChildPoList); + SetSelectedMasterFiles(FPoCheckerSettings.MasterPoSelList); + //AddToChildPoList(FPoCheckerSettings.ChildPoList); + { if (CompareText(ExtractFileExt(FPoCheckerSettings.LastSelectedFile), '.po') = 0) then begin if IsMasterPoName(FPoCheckerSettings.LastSelectedFile) then AddToMasterPoList(FPoCheckerSettings.LastSelectedFile) else AddToChildPoList(FPoCheckerSettings.LastSelectedFile); - SetSelectedPoName(FPoCheckerSettings.LastSelectedFile) + UpdateGUI(True) end else - SetSelectedPoName(''); + UpdateGUI(False); + } end; procedure TPoCheckerForm.SaveConfig; +var + SL: TStringList; begin - FPoCheckerSettings.LastSelectedFile := FSelectedPoName; FPoCheckerSettings.SelectDirectoryFilename := SelectDirectoryDialog.Filename; FPoCheckerSettings.OpenDialogFilename := OpenDialog.FileName; FPoCheckerSettings.TestTypes := GetTestTypesFromListBox; @@ -790,7 +727,12 @@ begin else FPoCheckerSettings.MainFormGeometry := Rect(RestoredLeft, RestoredTop, RestoredLeft + RestoredWidth, RestoredTop + RestoredHeight); FPoCheckerSettings.MasterPoList := MasterPoListBox.Items; - FPoCheckerSettings.ChildPoList := FChildPoList; + SL := GetSelectedMasterFiles; + try + FPoCheckerSettings.MasterPoSelList := SL; + finally + SL.Free; + end; FPoCheckerSettings.SaveConfig; end; diff --git a/components/pochecker/pocheckersettings.pp b/components/pochecker/pocheckersettings.pp index 0c7064ef25..8ea109aa24 100644 --- a/components/pochecker/pocheckersettings.pp +++ b/components/pochecker/pocheckersettings.pp @@ -30,13 +30,13 @@ type FTestTypes: TPoTestTypes; FTestOptions: TPoTestOptions; FMasterPoList: TStringList; - FChildPoList: TStringList; + FMasterPoSelList: TStringList; FLastSelectedFile: String; FMainFormGeometry: TRect; FGraphFormGeometry: TRect; FResultsFormGeometry: TRect; - function GetChildPoList: TStrings; function GetMasterPoList: TStrings; + function GetMasterPoSelList: TStrings; function LoadLastSelectedFile: String; function LoadTestTypes: TPoTestTypes; function LoadTestOptions: TPoTestOptions; @@ -45,8 +45,7 @@ type function LoadSelectDirectoryFilename: String; function LoadOpenDialogFilename: String; procedure LoadMasterPoList(List: TStrings); - procedure LoadChildPoList(List: TStrings); - procedure SaveLastSelectedFile; + procedure LoadMasterPoSelList(List: TStrings); procedure SaveTestTypes; procedure SaveTestOptions; procedure SaveWindowsGeometry; @@ -54,9 +53,9 @@ type procedure SaveSelectDirectoryFilename; procedure SaveOpenDialogFilename; procedure SaveMasterPoList; - procedure SaveChildrenPoList; - procedure SetChildPoList(AValue: TStrings); + procedure SaveMasterPoSelList; procedure SetMasterPoList(AValue: TStrings); + procedure SetMasterPoSelList(AValue: TStrings); procedure ResetAllProperties; public constructor Create; @@ -70,8 +69,7 @@ type property TestOptions: TPoTestOptions read FTestOptions write FTestOptions; property ExternalEditorName: String read FExternalEditorName write FExternalEditorName; property MasterPoList: TStrings read GetMasterPoList write SetMasterPoList; - property ChildPoList: TStrings read GetChildPoList write SetChildPoList; - property LastSelectedFile: String read FLastSelectedFile write FLastSelectedFile; + property MasterPoSelList: TStrings read GetMasterPoSelList write SetMasterPoSelList; property SelectDirectoryFilename: String read FSelectDirectoryFilename write FSelectDirectoryFilename; property OpenDialogFilename: String read FOpenDialogFilename write FOpenDialogFilename; property MainFormGeometry: TRect read FMainFormGeometry write FMainFormGeometry; @@ -158,6 +156,7 @@ const pWindowsGeometry = 'General/WindowsGeometry/'; pExternalEditor = 'ExternalEditor/'; pMasterPoFiles = 'MasterPoFiles/'; + pMasterPoSelection = 'MasterPoSelection/'; pChildPoFiles = 'ChildPoFiles/'; var @@ -240,11 +239,12 @@ begin Result := FMasterPoList; end; -function TPoCheckerSettings.GetChildPoList: TStrings; +function TPoCheckerSettings.GetMasterPoSelList: TStrings; begin - Result := FChildPoList; + Result := FMasterPoSelList; end; + function TPoCheckerSettings.LoadTestTypes: TPoTestTypes; var tt: TPoTestType; @@ -331,25 +331,21 @@ begin end; end; -procedure TPoCheckerSettings.LoadChildPoList(List: TStrings); +procedure TPoCheckerSettings.LoadMasterPoSelList(List: TStrings); var Cnt, i: Integer; Fn: String; begin List.Clear; - Cnt := Fconfig.GetValue(pChildPoFiles+'Count',0); - //debugln('TPoCheckerSettings.LoadChildPoList: Cnt = ',DbgS(Cnt)); + Cnt := Fconfig.GetValue(pMasterpoSelection+'Count',0); + //debugln('TPoCheckerSettings.LoadMasterPoSelList: Cnt = ',DbgS(Cnt)); for i := 0 to Cnt - 1 do begin - Fn := FConfig.GetValue(pChildPoFiles+Format('Item_%d/Value',[i]),''); + Fn := FConfig.GetValue(pMasterpoSelection+Format('Item_%d/Value',[i]),''); if (Fn <> '') then List.Add(Fn); end; end; -procedure TPoCheckerSettings.SaveLastSelectedFile; -begin - FConfig.SetDeleteValue(pLastSelected+'Value',FLastSelectedFile,''); -end; procedure TPoCheckerSettings.SaveTestTypes; var @@ -413,27 +409,29 @@ begin FConfig.SetDeleteValue(pMasterPoFiles+Format('Item_%d/Value',[i]),FMasterPoList[i],''); end; -procedure TPoCheckerSettings.SaveChildrenPoList; +procedure TPoCheckerSettings.SaveMasterPoSelList; var Cnt, i: Integer; begin - FConfig.DeletePath(pChildPoFiles); - Cnt := FChildPoList.Count; - FConfig.SetDeleteValue(pChildPoFiles+'Count',Cnt,0); + FConfig.DeletePath(pMasterPoSelection); + Cnt := FMasterPoSelList.Count; + FConfig.SetDeleteValue(pMasterPoSelection+'Count',Cnt,0); for i := 0 to Cnt - 1 do - FConfig.SetDeleteValue(pChildPoFiles+Format('Item_%d/Value',[i]),FChildPoList[i],''); + FConfig.SetDeleteValue(pMasterPoSelection+Format('Item_%d/Value',[i]),FMasterPoSelList[i],''); end; -procedure TPoCheckerSettings.SetChildPoList(AValue: TStrings); -begin - FChildPoList.Assign(AValue); -end; procedure TPoCheckerSettings.SetMasterPoList(AValue: TStrings); begin FMasterPoList.Assign(AValue); end; +procedure TPoCheckerSettings.SetMasterPoSelList(AValue: TStrings); +begin + FMasterPoSelList.Assign(AValue); +end; + + procedure TPoCheckerSettings.ResetAllProperties; begin FTestTypes := []; @@ -449,15 +447,14 @@ begin FSelectDirectoryFilename := ''; FLastSelectedFile := ''; if Assigned(FMasterPoList) then FMasterPoList.Free; + if Assigned(FMasterPoSelList) then FMasterPoSelList.Free; FMasterPoList := TStringList.Create; + FMasterPoSelList := TStringList.Create; FMasterPoList.Sorted := True; FMasterPoList.Duplicates := dupIgnore; - if Assigned(FChildPoList) then FChildPoList.Free; - FChildPoList := TStringList.Create; - FChildPoList.Sorted := True; - FChildPoList.Duplicates := dupIgnore; end; + constructor TPoCheckerSettings.Create; begin try @@ -488,7 +485,7 @@ destructor TPoCheckerSettings.Destroy; begin if Assigned(FConfig) then FConfig.Free; FMasterPoList.Free; - FChildPoList.Free; + FMasterPoSelList.Free; inherited Destroy; end; @@ -503,7 +500,7 @@ begin FExternalEditorName := LoadExternalEditorName; LoadWindowsGeometry; LoadMasterPoList(FMasterPoList); - LoadChildPoList(FChildPoList); + LoadMasterPoSelList(FMasterPoSelList); except ResetAllProperties; debugln('TPoCheckerSettings.LoadConfig: Error loading config.'); @@ -517,7 +514,6 @@ begin //the next line can be reomoved after some time FConfig.DeletePath(pLoadSettings); - SaveLastSelectedFile; SaveTestTypes; SaveTestOptions; SaveExternalEditorName; @@ -525,7 +521,10 @@ begin SaveOpenDialogFilename; SaveWindowsGeometry; SaveMasterPoList; - SaveChildrenPoList; + SaveMasterPoSelList; + //not used anymore, clear it. Remove this line after a while + FConfig.DeletePath(pChildPoFiles); + FConfig.WriteToDisk; except debugln('TPoCheckerSettings.SaveConfig: Error saving config.'); diff --git a/components/pochecker/pofamilies.pp b/components/pochecker/pofamilies.pp index 1901ae20ea..cf924fa2b6 100644 --- a/components/pochecker/pofamilies.pp +++ b/components/pochecker/pofamilies.pp @@ -122,6 +122,7 @@ Type public procedure Clear; procedure Add(AName: String; ANrTotal, ANrTranslated, ANrUnTranslated, ANrFuzzy, ANrErrors: Integer); + procedure AddItemsTo(APoFamilyStats: TPoFamilyStats); constructor Create; destructor Destroy; override; procedure AddStatisticsToLog(ALog: TStrings); @@ -135,11 +136,12 @@ function IsMasterPoName(const Fn: String): Boolean; function ExtractMasterNameFromChildName(const AChildName: String): String; function FindAllTranslatedPoFiles(const Filename: string): TStringList; +const + NoError = 0; implementation const - NoError = 0; sCommentIdentifier = '#: '; //sCharSetIdentifier = '"Content-Type: text/plain; charset='; sMsgID = 'msgid "'; @@ -389,6 +391,19 @@ begin FList.Add(TStat.Create(AName, ANrTotal, ANrTranslated, ANrUntranslated, ANrFuzzy, ANrErrors)); end; +procedure TPoFamilyStats.AddItemsTo(APoFamilyStats: TPoFamilyStats); +var + i: Integer; + AStat: TStat; +begin + for i := 0 to FList.Count - 1 do + begin + AStat := GetItems(i); + APoFamilyStats.Add(AStat.PoName, AStat.NrTotal, AStat.NrTranslated, + AStat.NrUntranslated, AStat.NrFuzzy, AStat.NrErrors); + end; +end; + constructor TPoFamilyStats.Create; begin FList := TFPObjectList.Create(True);