PoChecker: fix broken construction of language filename, introduced by me in r46530 #d1a01f5804.

git-svn-id: trunk@46531 -
This commit is contained in:
bart 2014-10-11 22:18:52 +00:00
parent d1a01f5804
commit cb35b5185b
2 changed files with 15 additions and 18 deletions

View File

@ -71,7 +71,7 @@ type
procedure ShowError(const Msg: string); procedure ShowError(const Msg: string);
function TrySelectFile(out Filename: String): Boolean; function TrySelectFile(out Filename: String): Boolean;
procedure ScanDirectory(ADir: String); procedure ScanDirectory(ADir: String);
function TryCreatepoFamilyList(MasterList: TStrings; const Lang: String): Boolean; function TryCreatepoFamilyList(MasterList: TStrings; const LangID: TLangID): Boolean;
procedure RunSelectedTests; procedure RunSelectedTests;
procedure ClearStatusBar; procedure ClearStatusBar;
procedure UpdateGUI(HasSelection: Boolean); procedure UpdateGUI(HasSelection: Boolean);
@ -212,16 +212,13 @@ procedure TPoCheckerForm.RunBtnClick(Sender: TObject);
var var
AMasterList: TStringList; AMasterList: TStringList;
LangIdx: Integer; LangIdx: Integer;
ALang: String; ALangID: TLangID;
begin begin
LangIdx := LangFilter.ItemIndex; LangIdx := LangFilter.ItemIndex;
if (LangIdx > 0) then ALangID := LangFilterIndexToLangID(LangIdx);
ALang := LangFilter.Items[LangIdx]
else
ALang := langAll;
AMasterList := GetSelectedMasterFiles; AMasterList := GetSelectedMasterFiles;
try try
if TryCreatePoFamilyList(AMasterList, ALang) then if TryCreatePoFamilyList(AMasterList, ALangID) then
RunSelectedTests RunSelectedTests
else else
begin begin
@ -466,7 +463,7 @@ begin
end; end;
function TPoCheckerForm.TryCreatepoFamilyList(MasterList: TStrings; const Lang: String): Boolean; function TPoCheckerForm.TryCreatepoFamilyList(MasterList: TStrings; const LangID: TLangID): Boolean;
var var
Fn, Msg: String; Fn, Msg: String;
i, Cnt: Integer; i, Cnt: Integer;
@ -498,7 +495,7 @@ begin
end; end;
try try
if Assigned(PoFamilyList) then PoFamilyList.Free; if Assigned(PoFamilyList) then PoFamilyList.Free;
PoFamilyList := TPoFamilyList.Create(MasterList, Lang, Msg); PoFamilyList := TPoFamilyList.Create(MasterList, LangID, Msg);
if (Msg <> '') then if (Msg <> '') then
begin begin
//MessageDlg('PoChecker',Format(sFilesNotFoundAndRemoved,[Msg]), mtInformation, [mbOk], 0); //MessageDlg('PoChecker',Format(sFilesNotFoundAndRemoved,[Msg]), mtInformation, [mbOk], 0);

View File

@ -7,7 +7,7 @@ interface
Uses Uses
Classes, SysUtils, LCLProc, FileUtil, StringHashList, ContNrs, Classes, SysUtils, LCLProc, FileUtil, StringHashList, ContNrs,
//{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF}, //{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF},
PoFamilies; PoFamilies, PoCheckerConsts;
const const
langAll = '*'; langAll = '*';
@ -19,7 +19,7 @@ type
TPoFamilyList = class TPoFamilyList = class
private private
FLang: String; FLangID: TLangID;
FList: TFPObjectList; FList: TFPObjectList;
FOnTestEnd: TTestEndEvent; FOnTestEnd: TTestEndEvent;
FOnTestStart: TTestStartEvent; FOnTestStart: TTestStartEvent;
@ -30,7 +30,7 @@ type
procedure DoTestStart(const ATestName, APoFileName: String); procedure DoTestStart(const ATestName, APoFileName: String);
procedure DoTestEnd(const ATestName: String; const ErrorCount: Integer); procedure DoTestEnd(const ATestName: String; const ErrorCount: Integer);
public public
constructor Create(AMasterList: TStrings; ALang: String; out Msg: String); constructor Create(AMasterList: TStrings; ALangID: TLangID; out Msg: String);
destructor Destroy; override; destructor Destroy; override;
procedure Add(PoFamily: TPofamily); procedure Add(PoFamily: TPofamily);
function Count: Integer; function Count: Integer;
@ -62,7 +62,7 @@ begin
if Assigned(FOnTestEnd) then FOnTestEnd(ATestName, ErrorCount); if Assigned(FOnTestEnd) then FOnTestEnd(ATestName, ErrorCount);
end; end;
constructor TPoFamilyList.Create(AMasterList: TStrings; ALang: String; out Msg: String); constructor TPoFamilyList.Create(AMasterList: TStrings; ALangID: TLangID; out Msg: String);
var var
i: Integer; i: Integer;
MasterName, ChildName: String; MasterName, ChildName: String;
@ -71,18 +71,18 @@ begin
FList := TFPObjectList.Create(True); FList := TFPObjectList.Create(True);
Msg := ''; Msg := '';
FPoFamilyStats := TPoFamilyStats.Create; FPoFamilyStats := TPoFamilyStats.Create;
FLang := ALang; FLangID := ALangID;
for i := 0 to AMasterList.Count - 1 do for i := 0 to AMasterList.Count - 1 do
begin begin
MasterName := AMasterList[i]; MasterName := AMasterList[i];
ChildName := ''; ChildName := '';
if FileExistsUtf8(MasterName) then if FileExistsUtf8(MasterName) then
begin begin
if (ALang <> langAll) then if (ALangID <> lang_all) then
ChildName := ChangeFileExt(MasterName, '.' + ALang + '.po'); ChildName := ChangeFileExt(MasterName, '.' + LanguageAbbr[ALangID] + '.po');
//debugln('TPoFamilyList.Create: i = ',DbgS(i),' Adding TPoFamily.Create(''',ExtractFileName(MasterName), //debugln('TPoFamilyList.Create: i = ',DbgS(i),' Adding TPoFamily.Create(''',ExtractFileName(MasterName),
// ''',',ExtractFileName(ChildName),''')'); // ''',',ExtractFileName(ChildName),''')');
if (ALang = langAll) or FileExistsUtf8(ChildName) then if (ALangID = lang_all) or FileExistsUtf8(ChildName) then
begin begin
APoFamily := TPoFamily.Create(MasterName, ChildName); APoFamily := TPoFamily.Create(MasterName, ChildName);
Add(APoFamily); Add(APoFamily);
@ -121,7 +121,7 @@ var
PoFamily: TPoFamily; PoFamily: TPoFamily;
//ThisLog: TStringList; //ThisLog: TStringList;
begin begin
if (FLang = langAll) then if (FLangID = lang_all) then
Include(TestOptions,ptoFindAllChildren) Include(TestOptions,ptoFindAllChildren)
else else
Exclude(TestOptions,ptoFindAllChildren); Exclude(TestOptions,ptoFindAllChildren);