mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 01:57:57 +02:00
Components, POChecker: unduplicated package and standalone project code
git-svn-id: trunk@36284 -
This commit is contained in:
parent
95114245f5
commit
578a8a2599
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2012,8 +2012,6 @@ components/plotfunction/tplotfunctionpanel.png -text svneol=unset#image/png
|
||||
components/pochecker/Proj/README.txt svneol=native#text/plain
|
||||
components/pochecker/Proj/pochecker.lpi svneol=native#text/plain
|
||||
components/pochecker/Proj/pochecker.lpr svneol=native#text/plain
|
||||
components/pochecker/Proj/pocheckermain.lfm svneol=native#text/plain
|
||||
components/pochecker/Proj/pocheckermain.pp svneol=native#text/plain
|
||||
components/pochecker/README.txt svneol=native#text/plain
|
||||
components/pochecker/languages/pocheckerconsts.de.po svneol=native#text/plain
|
||||
components/pochecker/languages/pocheckerconsts.po svneol=native#text/plain
|
||||
|
@ -46,35 +46,35 @@
|
||||
<UnitName Value="pochecker"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="pocheckermain.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="PoCheckerForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="pocheckermain"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\pofamilies.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="PoFamilies"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\resultdlg.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="ResultDlgForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="ResultDlg"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\simplepofiles.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="simplepofiles"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\pocheckerconsts.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="pocheckerconsts"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\pocheckermain.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="PoCheckerForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="pocheckermain"/>
|
||||
</Unit5>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
@ -100,6 +100,7 @@
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CustomOptions Value="-dPoCheckerStandAlone"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
|
@ -1,206 +0,0 @@
|
||||
object PoCheckerForm: TPoCheckerForm
|
||||
Left = 349
|
||||
Height = 311
|
||||
Top = 189
|
||||
Width = 581
|
||||
Caption = 'GUI Po-file checking tool'
|
||||
ClientHeight = 311
|
||||
ClientWidth = 581
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '0.9.31'
|
||||
Visible = True
|
||||
object TestListBox: TCheckListBox
|
||||
AnchorSideLeft.Control = SelectTestLabel
|
||||
AnchorSideTop.Control = SelectTestLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 201
|
||||
Height = 150
|
||||
Top = 28
|
||||
Width = 373
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
Enabled = False
|
||||
ItemHeight = 0
|
||||
TabOrder = 0
|
||||
end
|
||||
object SelectTestLabel: TLabel
|
||||
AnchorSideLeft.Control = OpenBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 201
|
||||
Height = 14
|
||||
Top = 8
|
||||
Width = 97
|
||||
BorderSpacing.Left = 9
|
||||
Caption = 'Select test types'
|
||||
Font.Style = [fsBold]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object OpenBtn: TBitBtn
|
||||
AnchorSideLeft.Control = RunBtn
|
||||
AnchorSideRight.Control = RunBtn
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = RunBtn
|
||||
Left = 8
|
||||
Height = 63
|
||||
Top = 33
|
||||
Width = 184
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
BorderSpacing.Bottom = 6
|
||||
Caption = '&Open a po-file'
|
||||
Glyph.Data = {
|
||||
36040000424D3604000000000000360000002800000010000000100000000100
|
||||
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00005E8E8D005D
|
||||
8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D8CBD005D
|
||||
8CBD005D8CBD005D8CBD005D8CBD005E8E8D005B8900005B890000679AB06AB7
|
||||
DAFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CCEDFF82CC
|
||||
EDFF82CCEDFF82CCEDFF83CDEEFF318DB9C9005E8E40005F8F000070A9A256AA
|
||||
CEFF80CBEAFF7EC9E9FF7EC9E9FF7EC9E9FF7EC9E9FF7EC9E9FF7EC9E9FF7EC9
|
||||
E9FF7EC9E9FF7EC9E9FF7EC9E9FF57AFD6D90066996E006699000074AD9D44A1
|
||||
CBFF8AD3EFFF83CDEBFF83CDEBFF83CDEBFF83CDEBFF83CDEBFF83CDEBFF83CD
|
||||
EBFF83CDEBFF83CDEBFF83CDEBFF81CDEBF2006FA8930071AB010076B29952B0
|
||||
D7FF85D2EDFF89D2EEFF89D2EEFF89D2EEFF89D2EEFF89D2EEFF89D2EEFF89D2
|
||||
EEFF89D2EEFF89D2EEFF89D2EEFF90D8F1FF228EC1AA0077B31D0079B69574CA
|
||||
E8FF75CAE8FF90D8F2FF8FD7F1FF8FD7F1FF8FD7F1FF8FD7F1FF8FD7F1FF8FD7
|
||||
F1FF8FD7F1FF8FD7F1FF8FD7F1FF91D8F2FF4FB1DAC2007FBD46007CBA928FDD
|
||||
F4FF63C0E5FFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EE
|
||||
FAFFA8EEFAFFA8EEFAFFA8EEFAFFA8EEFAFF86D8EFDE0083C571007FBD8EA6EC
|
||||
FCFF64C2E9FF4FB5E2FF4DB4E2FF4CB3E1FF4BB2E0FF49B1DFFF48B0DFFF47AE
|
||||
DEFF45ADDDFF44ACDDFF46AEDFFF0084C6C70087CB810087CB610081C18BABF0
|
||||
FEFFA4E9FCFFA2E7FBFF9FE5FAFF9CE3F8FF9AE1F7FF97DEF6FF94DCF4FF91D9
|
||||
F3FF8ED7F1FF8BD4F0FF90D8F3FF0081C18B0087CA000087CB000083C488ADF1
|
||||
FFFFA6EBFDFFA4E9FCFFA2E7FBFF9FE5FAFF9CE3F8FF9AE1F7FF97DEF6FF94DC
|
||||
F4FF91D9F3FF8ED7F1FF93DAF4FF0083C4880083C4000085C8000085C785B0F4
|
||||
FFFFADF1FFFFABF0FEFFA9EEFDFFA7ECFCFFA5EAFBFFA2E8FAFFA0E6F9FF9DE3
|
||||
F8FF9AE1F7FF98DFF6FF99E0F7FF0085C7850085C7000085C7000087CA620087
|
||||
CA830087CA830087CA830087CA830087CA830087CA83FEFEFDFFF5F5EEFFEBEB
|
||||
DDFFFEC941FFF4B62EFF0087CA830087CA620086C9000086C9000087CA000087
|
||||
CA000087CA000087CA000087CA000087CA000088CC2E0088CC810088CC810088
|
||||
CC810088CC810088CC810088CC2E0087CA000086C9000086C900FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
|
||||
}
|
||||
OnClick = OpenBtnClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object RunBtn: TBitBtn
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 63
|
||||
Top = 102
|
||||
Width = 184
|
||||
BorderSpacing.Top = 6
|
||||
Caption = '&Run Selected Tests'
|
||||
Enabled = False
|
||||
Kind = bkOK
|
||||
OnClick = RunBtnClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object StatusPanel: TPanel
|
||||
Left = 0
|
||||
Height = 49
|
||||
Top = 262
|
||||
Width = 581
|
||||
Align = alBottom
|
||||
BevelOuter = bvLowered
|
||||
ClientHeight = 49
|
||||
ClientWidth = 581
|
||||
TabOrder = 3
|
||||
object CurTestHeaderLabel: TLabel
|
||||
Left = 8
|
||||
Height = 14
|
||||
Top = 8
|
||||
Width = 66
|
||||
Caption = 'Current Test:'
|
||||
ParentColor = False
|
||||
end
|
||||
object CurPoHeaderLabel: TLabel
|
||||
AnchorSideLeft.Control = CurTestHeaderLabel
|
||||
AnchorSideTop.Control = CurTestHeaderLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 14
|
||||
Top = 22
|
||||
Width = 75
|
||||
Caption = 'Current po-file:'
|
||||
ParentColor = False
|
||||
end
|
||||
object CurTestLabel: TLabel
|
||||
AnchorSideLeft.Control = CurTestHeaderLabel
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = CurTestHeaderLabel
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 80
|
||||
Height = 14
|
||||
Top = 8
|
||||
Width = 64
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'CurTestLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object CurPoLabel: TLabel
|
||||
AnchorSideLeft.Control = CurPoHeaderLabel
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = CurPoHeaderLabel
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 89
|
||||
Height = 14
|
||||
Top = 22
|
||||
Width = 55
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'CurPoLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object NoErrLabel: TLabel
|
||||
Left = 8
|
||||
Height = 24
|
||||
Top = 232
|
||||
Width = 152
|
||||
Anchors = [akLeft, akBottom]
|
||||
Caption = 'No errors found'
|
||||
Font.Color = clGreen
|
||||
Font.Height = -19
|
||||
Font.Style = [fsBold]
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object SelectAllCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = TestListBox
|
||||
AnchorSideTop.Control = TestListBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 201
|
||||
Height = 17
|
||||
Top = 184
|
||||
Width = 61
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Select All'
|
||||
Enabled = False
|
||||
OnClick = SelectAllCheckBoxClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object FindAllPOsCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = SelectAllCheckBox
|
||||
AnchorSideTop.Control = SelectAllCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 201
|
||||
Height = 17
|
||||
Top = 207
|
||||
Width = 142
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'Find all translated PO files'
|
||||
TabOrder = 5
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
Filter = 'po-files (*.po)|*.po|all files|*'
|
||||
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]
|
||||
left = 40
|
||||
top = 512
|
||||
end
|
||||
end
|
@ -1,336 +0,0 @@
|
||||
{
|
||||
This source is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This code is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
A copy of the GNU General Public License is available on the World Wide Web
|
||||
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
|
||||
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA.
|
||||
}
|
||||
|
||||
// Original version made by Bart Broersma
|
||||
|
||||
unit pocheckermain;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, LCLProc, CheckLst, Buttons, ExtCtrls, Translations,
|
||||
SimplePoFiles, PoFamilies, ResultDlg, pocheckerconsts;
|
||||
|
||||
type
|
||||
|
||||
{ TPoCheckerForm }
|
||||
|
||||
TPoCheckerForm = class(TForm)
|
||||
FindAllPOsCheckBox: TCheckBox;
|
||||
SelectAllCheckBox: TCheckBox;
|
||||
CurTestHeaderLabel: TLabel;
|
||||
CurPoHeaderLabel: TLabel;
|
||||
CurTestLabel: TLabel;
|
||||
CurPoLabel: TLabel;
|
||||
NoErrLabel: TLabel;
|
||||
StatusPanel: TPanel;
|
||||
RunBtn: TBitBtn;
|
||||
OpenBtn: TBitBtn;
|
||||
Button3: TButton;
|
||||
SelectTestLabel: TLabel;
|
||||
OpenDialog: TOpenDialog;
|
||||
TestListBox: TCheckListBox;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure OpenBtnClick(Sender: TObject);
|
||||
procedure RunBtnClick(Sender: TObject);
|
||||
procedure SelectAllCheckBoxClick(Sender: TObject);
|
||||
private
|
||||
PoFamily: TPoFamily;
|
||||
FChoosenMasterName: String;
|
||||
FChoosenChildName: String;
|
||||
procedure OnTestStart(const ATestName, APoFileName: String);
|
||||
procedure OnTestEnd(const ATestName: String; const ErrorCount: Integer);
|
||||
procedure FillTestListBox;
|
||||
function GetOptionsFromListBox: TPoTestOptions;
|
||||
procedure ShowError(const Msg: String);
|
||||
function TrySelectFile: Boolean;
|
||||
procedure RunSelectedTests;
|
||||
procedure ClearAndDisableStatusPanel;
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
PoCheckerForm: TPoCheckerForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TPoCheckerForm }
|
||||
|
||||
procedure TPoCheckerForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
Lang, T: string;
|
||||
begin
|
||||
//Initializing translation
|
||||
Lang := GetEnvironmentVariableUTF8('LANG');
|
||||
if Lang = '' then
|
||||
LCLGetLanguageIDs(Lang, T);
|
||||
if Lang <> '' then
|
||||
begin
|
||||
Lang := copy(Lang, 1, 2);
|
||||
Translations.TranslateUnitResourceStrings('PoCheckerConsts', '..'+DirectorySeparator+'languages'+DirectorySeparator+'pocheckerconsts.'+Lang+'.po');
|
||||
Translations.TranslateUnitResourceStrings('LCLStrConsts', '..'+DirectorySeparator+'languages'+DirectorySeparator+'lclstrconsts.'+Lang+'.po');
|
||||
end;
|
||||
|
||||
Caption := sGUIPoFileCheckingTool;
|
||||
SelectTestLabel.Caption := sSelectTestTypes;
|
||||
FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles;
|
||||
OpenBtn.Caption := sOpenAPoFile;
|
||||
RunBtn.Caption := sRunSelectedTests;
|
||||
NoErrLabel.Caption := sNoErrorsFound;
|
||||
FillTestListBox;
|
||||
ClearAndDisableStatusPanel;
|
||||
NoErrLabel.Visible := False;
|
||||
CurTestHeaderLabel.Caption := sCurrentTest;
|
||||
CurPoHeaderLabel.Caption := sCurrentPoFile;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
if Assigned(PoFamily) then PoFamily.Free;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.OpenBtnClick(Sender: TObject);
|
||||
begin
|
||||
if TrySelectFile then
|
||||
begin
|
||||
RunBtn.Enabled := True;
|
||||
TestListBox.Enabled := True;
|
||||
SelectAllCheckBox.Enabled := True;
|
||||
end
|
||||
else begin
|
||||
RunBtn.Enabled := False;
|
||||
TestListBox.Enabled := False;
|
||||
SelectAllCheckBox.Enabled := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.RunBtnClick(Sender: TObject);
|
||||
begin
|
||||
RunSelectedTests;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.SelectAllCheckBoxClick(Sender: TObject);
|
||||
var
|
||||
cb: TCheckBox;
|
||||
i: Integer;
|
||||
begin
|
||||
cb := Sender as TCheckBox;
|
||||
// Caption text : select all / unselect all
|
||||
if cb.Checked then
|
||||
cb.Caption := sUnSelectAllTests
|
||||
else
|
||||
cb.Caption := sSelectAllTests;
|
||||
// Set / reset all CheckListBox items.
|
||||
for i := 0 to TestListBox.Count - 1 do
|
||||
TestListBox.Checked[i] := cb.Checked;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: String);
|
||||
begin
|
||||
//debugln('OnTestStart: ATestName = "',AtestName,'" APoFileName = "',APoFileName);
|
||||
CurTestLabel.Caption := ATestName;
|
||||
CurPoLabel.Caption := APoFileName;
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.OnTestEnd(const ATestName: String; const ErrorCount: Integer);
|
||||
begin
|
||||
//CurTestLabel.Caption := '';
|
||||
//CurPoLabel.Caption := '';
|
||||
debugln('OnTestEnd [',ATestName,']: ErrorCount = ',DbgS(ErrorCount));
|
||||
//Application.ProcessMessages;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.FillTestListBox;
|
||||
var
|
||||
Opt: TPoTestOption;
|
||||
begin
|
||||
for Opt := Low(PoTestOptionNames) to Pred(High(PoTestOptionNames)) do
|
||||
case Opt of
|
||||
ptoCheckNrOfItems: TestListBox.Items.Add(sCheckNumberOfItems);
|
||||
ptoCheckFormatArgs: TestListBox.Items.Add(sCheckForIncompatibleFormatArguments);
|
||||
ptoCheckMissingIdentifiers: TestListBox.Items.Add(sCheckMissingIdentifiers);
|
||||
ptoCheckMismatchedOriginals: TestListBox.Items.Add(sCheckForMismatchesInUntranslatedStrings);
|
||||
ptoCheckDuplicateOriginals: TestListBox.Items.Add(sCheckForDuplicateUntranslatedValues);
|
||||
else
|
||||
TestListBox.Items.Add(PoTestOptionNames[Opt]);
|
||||
end;
|
||||
SelectAllCheckBox.Caption := sSelectAllTests;
|
||||
end;
|
||||
|
||||
function TPoCheckerForm.GetOptionsFromListBox: TPoTestOptions;
|
||||
var
|
||||
Opt: TPoTestOption;
|
||||
Index: Integer;
|
||||
begin
|
||||
Result := [];
|
||||
for Opt := Low(TpoTestOption) to Pred(High(TPoTestOption)) do
|
||||
begin
|
||||
Index := Ord(Opt);
|
||||
if (Index < TestListBox.Count) then
|
||||
begin
|
||||
if TestListBox.Checked[Index] then
|
||||
Result := Result + [Opt];
|
||||
end;
|
||||
end;
|
||||
if FindAllPOsCheckBox.Checked then
|
||||
Result := Result + [High(TPoTestOption)];
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.ShowError(const Msg: String);
|
||||
begin
|
||||
MessageDlg('Po-checker', Msg, mtError, [mbOk], 0);
|
||||
end;
|
||||
|
||||
function TPoCheckerForm.TrySelectFile: Boolean;
|
||||
var
|
||||
Fn: String;
|
||||
ShortFn: String;
|
||||
OK: Boolean;
|
||||
begin
|
||||
NoErrLabel.Visible := False;
|
||||
OK := False;
|
||||
if OpenDialog.Execute then
|
||||
begin
|
||||
Fn := OpenDialog.FileName;
|
||||
ShortFn := ExtractFileName(Fn);
|
||||
if IsMasterPoName(Fn) then
|
||||
begin
|
||||
FChoosenMasterName := Fn;
|
||||
FChoosenChildName := '';
|
||||
end
|
||||
else
|
||||
begin //not a mastername, may be a child
|
||||
FChoosenChildName := Fn;
|
||||
FChoosenMasterName := ExtractMasterNameFromChildName(Fn);
|
||||
if (FChoosenMasterName = '') then
|
||||
begin
|
||||
FChoosenMasterName := '';
|
||||
FChoosenChildName := '';
|
||||
ShowError(Format(sNotAProperFileName,[ShortFn]));
|
||||
end
|
||||
else if not FileExistsUtf8(FChoosenMasterName) then
|
||||
begin
|
||||
FChoosenMasterName := '';
|
||||
FChoosenChildName := '';
|
||||
ShowError(Format(sCannotFindMaster,[ShortFn]));
|
||||
end;
|
||||
end;
|
||||
OK := (FChoosenMasterName <> '');
|
||||
if OK then
|
||||
begin
|
||||
if Assigned(PoFamily) then
|
||||
PoFamily.Free;
|
||||
try
|
||||
PoFamily := TPoFamily.Create(FChoosenMasterName, FChoosenChildName);
|
||||
PoFamily.OnTestStart := @OnTestStart;
|
||||
PoFamily.OnTestEnd := @OnTestEnd;
|
||||
except
|
||||
on E: Exception do
|
||||
begin
|
||||
OK := 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;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result := OK;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.RunSelectedTests;
|
||||
var
|
||||
Options: TPoTestOptions;
|
||||
ErrorCount, WarningCount: Integer;
|
||||
SL: TStrings;
|
||||
ResultDlg: TResultDlgForm;
|
||||
begin
|
||||
Options := GetOptionsFromListBox;
|
||||
if (Options = []) then
|
||||
begin
|
||||
ShowError(sNoTestSelected);
|
||||
Exit;
|
||||
end;
|
||||
NoErrLabel.Visible := False;
|
||||
Application.ProcessMessages;
|
||||
SL := TStringList.Create;
|
||||
try
|
||||
StatusPanel.Enabled := True;
|
||||
if (not (ptoFindAllChilds in Options)) and Assigned(PoFamily.Child)
|
||||
and (PoFamily.ChildName <> FChoosenChildName) then
|
||||
PoFamily.ChildName := FChoosenChildName;
|
||||
PoFamily.RunTests(Options, ErrorCount, WarningCount, SL);
|
||||
debugln('RunSelectedTests: ',Format(sTotalErrors,[ErrorCount]));
|
||||
debugln(' ',Format(sTotalWarnings,[WarningCount]));
|
||||
if (ErrorCount > 0) or (WarningCount > 0) then
|
||||
begin
|
||||
SL.Add(Format(sTotalErrors,[ErrorCount]));
|
||||
SL.Add(Format(sTotalWarnings,[WarningCount]));
|
||||
ResultDlg := TResultDlgForm.Create(Nil);
|
||||
try
|
||||
ResultDlg.Log.Assign(SL);
|
||||
FreeAndNil(SL); //No need to keep 2 copies of this data
|
||||
ResultDlg.ShowModal;
|
||||
finally
|
||||
ResultDlg.Free;
|
||||
end;
|
||||
end;
|
||||
NoErrLabel.Visible := (ErrorCount = 0);
|
||||
finally
|
||||
if Assigned(SL) then
|
||||
SL.Free;
|
||||
ClearAndDisableStatusPanel;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.ClearAndDisableStatusPanel;
|
||||
begin
|
||||
CurTestLabel.Caption := '';
|
||||
CurPoLabel.Caption := '';
|
||||
StatusPanel.Enabled := False;
|
||||
end;
|
||||
|
||||
|
||||
function SameItem(Item1, Item2: TPoFileItem): Boolean;
|
||||
begin
|
||||
Result := (Item1.Identifier = Item2.Identifier) and
|
||||
(Item1.Original = Item2.Original) and
|
||||
(Item1.Context = Item2.Context) and
|
||||
(Item1.Flags = Item2.Flags) and
|
||||
(Item1.PreviousID = Item2.PreviousID) and
|
||||
(Item1.Translation = Item2.Translation);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -26,6 +26,9 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, LCLProc, CheckLst, Buttons, ExtCtrls, IDEIntf, MenuIntf,
|
||||
{$IFDEF POCHECKERSTANDALONE}
|
||||
Translations,
|
||||
{$ENDIF}
|
||||
SimplePoFiles, PoFamilies, ResultDlg, pocheckerconsts;
|
||||
|
||||
type
|
||||
@ -88,7 +91,24 @@ end;
|
||||
{ TPoCheckerForm }
|
||||
|
||||
procedure TPoCheckerForm.FormCreate(Sender: TObject);
|
||||
{$IFDEF POCHECKERSTANDALONE}
|
||||
var
|
||||
Lang, T: string;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF POCHECKERSTANDALONE}
|
||||
//Initializing translation
|
||||
Lang := GetEnvironmentVariableUTF8('LANG');
|
||||
if Lang = '' then
|
||||
LCLGetLanguageIDs(Lang, T);
|
||||
if Lang <> '' then
|
||||
begin
|
||||
Lang := copy(Lang, 1, 2);
|
||||
Translations.TranslateUnitResourceStrings('PoCheckerConsts', '..'+DirectorySeparator+'languages'+DirectorySeparator+'pocheckerconsts.'+Lang+'.po');
|
||||
Translations.TranslateUnitResourceStrings('LCLStrConsts', '..'+DirectorySeparator+'languages'+DirectorySeparator+'lclstrconsts.'+Lang+'.po');
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Caption := sGUIPoFileCheckingTool;
|
||||
SelectTestLabel.Caption := sSelectTestTypes;
|
||||
FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles;
|
||||
|
Loading…
Reference in New Issue
Block a user