mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 10:09:14 +02:00
PoChecker: refactor initialization of translation strings.
git-svn-id: trunk@46547 -
This commit is contained in:
parent
64f76cdac8
commit
4b3bc597fc
@ -85,6 +85,10 @@ type
|
|||||||
function LangFilterIndexToLangID(Index: Integer): TLangID;
|
function LangFilterIndexToLangID(Index: Integer): TLangID;
|
||||||
function LangIdToLangFilterIndex(LangID: TLangID): Integer;
|
function LangIdToLangFilterIndex(LangID: TLangID): Integer;
|
||||||
procedure PopulateLangFilter;
|
procedure PopulateLangFilter;
|
||||||
|
{$IFDEF POCHECKERSTANDALONE}
|
||||||
|
procedure GetTranslations;
|
||||||
|
{$ENDIF}
|
||||||
|
procedure ApplyTranslations;
|
||||||
published
|
published
|
||||||
IgnoreFuzzyCheckBox: TCheckBox;
|
IgnoreFuzzyCheckBox: TCheckBox;
|
||||||
UnselectAllTestsBtn: TButton;
|
UnselectAllTestsBtn: TButton;
|
||||||
@ -127,53 +131,16 @@ end;
|
|||||||
{ TPoCheckerForm }
|
{ TPoCheckerForm }
|
||||||
|
|
||||||
procedure TPoCheckerForm.FormCreate(Sender: TObject);
|
procedure TPoCheckerForm.FormCreate(Sender: TObject);
|
||||||
{$IFDEF POCHECKERSTANDALONE}
|
|
||||||
var
|
|
||||||
Lang, T, AppPath: string;
|
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
//debugln('TPoCheckerForm.FormCreate A:');
|
//debugln('TPoCheckerForm.FormCreate A:');
|
||||||
{$IFDEF POCHECKERSTANDALONE}
|
{$IFDEF POCHECKERSTANDALONE}
|
||||||
//Initializing translation
|
//Initializing translation
|
||||||
Lang := GetEnvironmentVariableUTF8('LANG');
|
GetTranslations;
|
||||||
T := '';
|
|
||||||
if Lang = '' then
|
|
||||||
LCLGetLanguageIDs(Lang, T);
|
|
||||||
if Lang <> '' then
|
|
||||||
begin
|
|
||||||
{$ifdef windows}
|
|
||||||
AppPath := ExtractFilePath(ParamStr(0));
|
|
||||||
{$else}
|
|
||||||
AppPath := '';
|
|
||||||
{$endif}
|
|
||||||
Lang := copy(Lang, 1, 2);
|
|
||||||
Translations.TranslateUnitResourceStrings('PoCheckerConsts',
|
|
||||||
AppPath + '..' + DirectorySeparator + 'languages' + DirectorySeparator +
|
|
||||||
'pocheckerconsts.' + Lang + '.po');
|
|
||||||
//requires the user copies the LCLStrConsts translations there!
|
|
||||||
Translations.TranslateUnitResourceStrings('LCLStrConsts',
|
|
||||||
AppPath + '..' + DirectorySeparator + 'languages' + DirectorySeparator +
|
|
||||||
'lclstrconsts.' + Lang + '.po');
|
|
||||||
end;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Caption := sGUIPoFileCheckingTool;
|
ApplyTranslations;
|
||||||
SelectTestLabel.Caption := sSelectTestTypes;
|
|
||||||
//FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles;
|
|
||||||
IgnoreFuzzyCheckBox.Caption := sIgnoreFuzzyTranslations;
|
|
||||||
OpenBtn.Caption := sOpenAPoFile;
|
|
||||||
ScanDirBtn.Caption := sScanDir;
|
|
||||||
RunBtn.Caption := sRunSelectedTests;
|
|
||||||
ClearMasterFilesBtn.Caption := sClearListBox;
|
|
||||||
UnselectAllMasterFilesBtn.Caption := sUnselectListBox;
|
|
||||||
SelectAllMasterFilesBtn.Caption := sSelectAllListBox;
|
|
||||||
LangFilter.Items[0] := sAllLanguages;
|
|
||||||
NoErrLabel.Caption := sNoErrorsFound;
|
|
||||||
FillTestListBox;
|
FillTestListBox;
|
||||||
ClearStatusBar;
|
ClearStatusBar;
|
||||||
NoErrLabel.Visible := False;
|
NoErrLabel.Visible := False;
|
||||||
SelectAllTestsBtn.Caption := sSelectAllTests;
|
|
||||||
SelectBasicTestsBtn.Caption := sSelectBasicTests;
|
|
||||||
UnselectAllTestsBtn.Caption := sUnselectAllTests;
|
|
||||||
PopulateLangFilter;
|
PopulateLangFilter;
|
||||||
LoadConfig;
|
LoadConfig;
|
||||||
LangFilter.Invalidate; //Items[0] may have been changed
|
LangFilter.Invalidate; //Items[0] may have been changed
|
||||||
@ -358,23 +325,8 @@ var
|
|||||||
begin
|
begin
|
||||||
TestListBox.Items.Clear;
|
TestListBox.Items.Clear;
|
||||||
for Typ := Low(PoTestTypeNames) to High(PoTestTypeNames) do
|
for Typ := Low(PoTestTypeNames) to High(PoTestTypeNames) do
|
||||||
case Typ of
|
|
||||||
pttCheckNrOfItems:
|
|
||||||
TestListBox.Items.Add(sCheckNumberOfItems);
|
|
||||||
pttCheckFormatArgs:
|
|
||||||
TestListBox.Items.Add(sCheckForIncompatibleFormatArguments);
|
|
||||||
pttCheckMissingIdentifiers:
|
|
||||||
TestListBox.Items.Add(sCheckMissingIdentifiers);
|
|
||||||
pttCheckMismatchedOriginals:
|
|
||||||
TestListBox.Items.Add(sCheckForMismatchesInUntranslatedStrings);
|
|
||||||
pttCheckDuplicateOriginals:
|
|
||||||
TestListBox.Items.Add(sCheckForDuplicateUntranslatedValues);
|
|
||||||
pttCheckStatistics:
|
|
||||||
TestListBox.Items.Add(sCheckStatistics);
|
|
||||||
else
|
|
||||||
TestListBox.Items.Add(PoTestTypeNames[Typ]);
|
TestListBox.Items.Add(PoTestTypeNames[Typ]);
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function TPoCheckerForm.GetTestTypesFromListBox: TPoTestTypes;
|
function TPoCheckerForm.GetTestTypesFromListBox: TPoTestTypes;
|
||||||
@ -825,7 +777,6 @@ var
|
|||||||
SL: TStringList;
|
SL: TStringList;
|
||||||
begin
|
begin
|
||||||
LangFilter.Items.BeginUpdate;
|
LangFilter.Items.BeginUpdate;
|
||||||
LocalizeLanguageNames;
|
|
||||||
SL := TStringList.Create;
|
SL := TStringList.Create;
|
||||||
try
|
try
|
||||||
LangFilter.Items.Clear;
|
LangFilter.Items.Clear;
|
||||||
@ -848,6 +799,55 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF POCHECKERSTANDALONE}
|
||||||
|
procedure TPoCheckerForm.GetTranslations;
|
||||||
|
var
|
||||||
|
Lang, T, AppPath: string;
|
||||||
|
begin
|
||||||
|
Lang := GetEnvironmentVariableUTF8('LANG');
|
||||||
|
T := '';
|
||||||
|
if Lang = '' then
|
||||||
|
LCLGetLanguageIDs(Lang, T);
|
||||||
|
if Lang <> '' then
|
||||||
|
begin
|
||||||
|
{$ifdef windows}
|
||||||
|
AppPath := ExtractFilePath(ParamStr(0));
|
||||||
|
{$else}
|
||||||
|
AppPath := '';
|
||||||
|
{$endif}
|
||||||
|
Lang := copy(Lang, 1, 2);
|
||||||
|
Translations.TranslateUnitResourceStrings('PoCheckerConsts',
|
||||||
|
AppPath + '..' + DirectorySeparator + 'languages' + DirectorySeparator +
|
||||||
|
'pocheckerconsts.' + Lang + '.po');
|
||||||
|
//requires the user copies the LCLStrConsts translations there!
|
||||||
|
Translations.TranslateUnitResourceStrings('LCLStrConsts',
|
||||||
|
AppPath + '..' + DirectorySeparator + 'languages' + DirectorySeparator +
|
||||||
|
'lclstrconsts.' + Lang + '.po');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
procedure TPoCheckerForm.ApplyTranslations;
|
||||||
|
begin
|
||||||
|
LocalizePoTestTypeNames;
|
||||||
|
LocalizeLanguageNames;
|
||||||
|
Caption := sGUIPoFileCheckingTool;
|
||||||
|
SelectTestLabel.Caption := sSelectTestTypes;
|
||||||
|
//FindAllPOsCheckBox.Caption := sFindAllTranslatedPoFiles;
|
||||||
|
IgnoreFuzzyCheckBox.Caption := sIgnoreFuzzyTranslations;
|
||||||
|
OpenBtn.Caption := sOpenAPoFile;
|
||||||
|
ScanDirBtn.Caption := sScanDir;
|
||||||
|
RunBtn.Caption := sRunSelectedTests;
|
||||||
|
ClearMasterFilesBtn.Caption := sClearListBox;
|
||||||
|
UnselectAllMasterFilesBtn.Caption := sUnselectListBox;
|
||||||
|
SelectAllMasterFilesBtn.Caption := sSelectAllListBox;
|
||||||
|
LangFilter.Items[0] := sAllLanguages;
|
||||||
|
NoErrLabel.Caption := sNoErrorsFound;
|
||||||
|
SelectAllTestsBtn.Caption := sSelectAllTests;
|
||||||
|
SelectBasicTestsBtn.Caption := sSelectBasicTests;
|
||||||
|
UnselectAllTestsBtn.Caption := sUnselectAllTests;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function SameItem(Item1, Item2: TPoFileItem): boolean;
|
function SameItem(Item1, Item2: TPoFileItem): boolean;
|
||||||
begin
|
begin
|
||||||
|
@ -137,6 +137,7 @@ function ExtractFormatArgs(S: String; out ArgumentError: Integer): String;
|
|||||||
function IsMasterPoName(const Fn: String): Boolean;
|
function IsMasterPoName(const Fn: String): Boolean;
|
||||||
function ExtractMasterNameFromChildName(const AChildName: String): String;
|
function ExtractMasterNameFromChildName(const AChildName: String): String;
|
||||||
function FindAllTranslatedPoFiles(const Filename: string): TStringList;
|
function FindAllTranslatedPoFiles(const Filename: string): TStringList;
|
||||||
|
procedure LocalizePoTestTypeNames;
|
||||||
|
|
||||||
const
|
const
|
||||||
NoError = 0;
|
NoError = 0;
|
||||||
@ -162,11 +163,11 @@ const
|
|||||||
sMismatchOriginalsM = '%s: %s';
|
sMismatchOriginalsM = '%s: %s';
|
||||||
sMismatchOriginalsC = '%s: %s';
|
sMismatchOriginalsC = '%s: %s';
|
||||||
|
|
||||||
sCheckFormatArgs = 'CheckFormatArgs';
|
sShortCheckFormatArgs = 'CheckFormatArgs';
|
||||||
sCheckNrOfItems = 'CheckNrOfItems';
|
sShortCheckNrOfItems = 'CheckNrOfItems';
|
||||||
sCheckMissingIdentifiers = 'CheckMissingIdentifiers';
|
sShortCheckMissingIdentifiers = 'CheckMissingIdentifiers';
|
||||||
sCheckMismatchedOriginals = 'CheckMismatchedOriginals';
|
sShortCheckMismatchedOriginals = 'CheckMismatchedOriginals';
|
||||||
sCheckDuplicateOriginals = 'CheckDuplicateOriginals';
|
sShortCheckDuplicateOriginals = 'CheckDuplicateOriginals';
|
||||||
|
|
||||||
//Helper functions
|
//Helper functions
|
||||||
|
|
||||||
@ -286,6 +287,16 @@ begin
|
|||||||
FindCloseUTF8(FileInfo);
|
FindCloseUTF8(FileInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LocalizePoTestTypeNames;
|
||||||
|
begin
|
||||||
|
PoTestTypeNames[pttCheckNrOfItems] := sCheckNumberOfItems;
|
||||||
|
PoTestTypeNames[pttCheckFormatArgs] := sCheckForIncompatibleFormatArguments;
|
||||||
|
PoTestTypeNames[pttCheckMissingIdentifiers] := sCheckMissingIdentifiers;
|
||||||
|
PoTestTypeNames[pttCheckMismatchedOriginals] := sCheckForMismatchesInUntranslatedStrings;
|
||||||
|
PoTestTypeNames[pttCheckDuplicateOriginals] := sCheckForDuplicateUntranslatedValues;
|
||||||
|
PoTestTypeNames[pttCheckStatistics] := sCheckStatistics;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function CompareFormatArgs(S1, S2: String): Boolean;
|
function CompareFormatArgs(S1, S2: String): Boolean;
|
||||||
@ -542,7 +553,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
ErrorCount := 1;
|
ErrorCount := 1;
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckNrOfItems]));
|
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckNrOfItems]));
|
||||||
ErrorLog.Add(ShortChildName);
|
ErrorLog.Add(ShortChildName);
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add('');
|
ErrorLog.Add('');
|
||||||
@ -583,7 +594,7 @@ begin
|
|||||||
if (ErrorCount = 0) then
|
if (ErrorCount = 0) then
|
||||||
begin
|
begin
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckFormatArgs]));
|
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckFormatArgs]));
|
||||||
ErrorLog.Add(ShortChildName);
|
ErrorLog.Add(ShortChildName);
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add('');
|
ErrorLog.Add('');
|
||||||
@ -629,7 +640,7 @@ begin
|
|||||||
if (ErrorCount = 0) then
|
if (ErrorCount = 0) then
|
||||||
begin
|
begin
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckMissingIdentifiers]));
|
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckMissingIdentifiers]));
|
||||||
ErrorLog.Add(ShortChildName);
|
ErrorLog.Add(ShortChildName);
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add('');
|
ErrorLog.Add('');
|
||||||
@ -655,7 +666,7 @@ begin
|
|||||||
if (ErrorCount = 0) then
|
if (ErrorCount = 0) then
|
||||||
begin
|
begin
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckMissingIdentifiers]));
|
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckMissingIdentifiers]));
|
||||||
ErrorLog.Add(ShortChildName);
|
ErrorLog.Add(ShortChildName);
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add('');
|
ErrorLog.Add('');
|
||||||
@ -700,7 +711,7 @@ begin
|
|||||||
if (ErrorCount = 0) then
|
if (ErrorCount = 0) then
|
||||||
begin
|
begin
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckMismatchedOriginals]));
|
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckMismatchedOriginals]));
|
||||||
ErrorLog.Add(ShortChildName);
|
ErrorLog.Add(ShortChildName);
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add('');
|
ErrorLog.Add('');
|
||||||
@ -750,7 +761,7 @@ begin
|
|||||||
if (WarningCount = 0) then
|
if (WarningCount = 0) then
|
||||||
begin
|
begin
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckDuplicateOriginals]));
|
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckDuplicateOriginals]));
|
||||||
ErrorLog.Add(ShortMasterName);
|
ErrorLog.Add(ShortMasterName);
|
||||||
ErrorLog.Add(Divider);
|
ErrorLog.Add(Divider);
|
||||||
ErrorLog.Add('');
|
ErrorLog.Add('');
|
||||||
|
Loading…
Reference in New Issue
Block a user