mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 20:59:08 +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 LangIdToLangFilterIndex(LangID: TLangID): Integer;
|
||||
procedure PopulateLangFilter;
|
||||
{$IFDEF POCHECKERSTANDALONE}
|
||||
procedure GetTranslations;
|
||||
{$ENDIF}
|
||||
procedure ApplyTranslations;
|
||||
published
|
||||
IgnoreFuzzyCheckBox: TCheckBox;
|
||||
UnselectAllTestsBtn: TButton;
|
||||
@ -127,53 +131,16 @@ end;
|
||||
{ TPoCheckerForm }
|
||||
|
||||
procedure TPoCheckerForm.FormCreate(Sender: TObject);
|
||||
{$IFDEF POCHECKERSTANDALONE}
|
||||
var
|
||||
Lang, T, AppPath: string;
|
||||
{$ENDIF}
|
||||
begin
|
||||
//debugln('TPoCheckerForm.FormCreate A:');
|
||||
{$IFDEF POCHECKERSTANDALONE}
|
||||
//Initializing translation
|
||||
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;
|
||||
GetTranslations;
|
||||
{$ENDIF}
|
||||
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;
|
||||
ApplyTranslations;
|
||||
FillTestListBox;
|
||||
ClearStatusBar;
|
||||
NoErrLabel.Visible := False;
|
||||
SelectAllTestsBtn.Caption := sSelectAllTests;
|
||||
SelectBasicTestsBtn.Caption := sSelectBasicTests;
|
||||
UnselectAllTestsBtn.Caption := sUnselectAllTests;
|
||||
PopulateLangFilter;
|
||||
LoadConfig;
|
||||
LangFilter.Invalidate; //Items[0] may have been changed
|
||||
@ -358,22 +325,7 @@ var
|
||||
begin
|
||||
TestListBox.Items.Clear;
|
||||
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]);
|
||||
end;
|
||||
TestListBox.Items.Add(PoTestTypeNames[Typ]);
|
||||
end;
|
||||
|
||||
|
||||
@ -825,7 +777,6 @@ var
|
||||
SL: TStringList;
|
||||
begin
|
||||
LangFilter.Items.BeginUpdate;
|
||||
LocalizeLanguageNames;
|
||||
SL := TStringList.Create;
|
||||
try
|
||||
LangFilter.Items.Clear;
|
||||
@ -848,6 +799,55 @@ begin
|
||||
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;
|
||||
begin
|
||||
|
@ -137,6 +137,7 @@ function ExtractFormatArgs(S: String; out ArgumentError: Integer): String;
|
||||
function IsMasterPoName(const Fn: String): Boolean;
|
||||
function ExtractMasterNameFromChildName(const AChildName: String): String;
|
||||
function FindAllTranslatedPoFiles(const Filename: string): TStringList;
|
||||
procedure LocalizePoTestTypeNames;
|
||||
|
||||
const
|
||||
NoError = 0;
|
||||
@ -162,11 +163,11 @@ const
|
||||
sMismatchOriginalsM = '%s: %s';
|
||||
sMismatchOriginalsC = '%s: %s';
|
||||
|
||||
sCheckFormatArgs = 'CheckFormatArgs';
|
||||
sCheckNrOfItems = 'CheckNrOfItems';
|
||||
sCheckMissingIdentifiers = 'CheckMissingIdentifiers';
|
||||
sCheckMismatchedOriginals = 'CheckMismatchedOriginals';
|
||||
sCheckDuplicateOriginals = 'CheckDuplicateOriginals';
|
||||
sShortCheckFormatArgs = 'CheckFormatArgs';
|
||||
sShortCheckNrOfItems = 'CheckNrOfItems';
|
||||
sShortCheckMissingIdentifiers = 'CheckMissingIdentifiers';
|
||||
sShortCheckMismatchedOriginals = 'CheckMismatchedOriginals';
|
||||
sShortCheckDuplicateOriginals = 'CheckDuplicateOriginals';
|
||||
|
||||
//Helper functions
|
||||
|
||||
@ -286,6 +287,16 @@ begin
|
||||
FindCloseUTF8(FileInfo);
|
||||
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;
|
||||
@ -542,7 +553,7 @@ begin
|
||||
begin
|
||||
ErrorCount := 1;
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckNrOfItems]));
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckNrOfItems]));
|
||||
ErrorLog.Add(ShortChildName);
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add('');
|
||||
@ -583,7 +594,7 @@ begin
|
||||
if (ErrorCount = 0) then
|
||||
begin
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckFormatArgs]));
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckFormatArgs]));
|
||||
ErrorLog.Add(ShortChildName);
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add('');
|
||||
@ -629,7 +640,7 @@ begin
|
||||
if (ErrorCount = 0) then
|
||||
begin
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckMissingIdentifiers]));
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckMissingIdentifiers]));
|
||||
ErrorLog.Add(ShortChildName);
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add('');
|
||||
@ -655,7 +666,7 @@ begin
|
||||
if (ErrorCount = 0) then
|
||||
begin
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckMissingIdentifiers]));
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckMissingIdentifiers]));
|
||||
ErrorLog.Add(ShortChildName);
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add('');
|
||||
@ -700,7 +711,7 @@ begin
|
||||
if (ErrorCount = 0) then
|
||||
begin
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckMismatchedOriginals]));
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckMismatchedOriginals]));
|
||||
ErrorLog.Add(ShortChildName);
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add('');
|
||||
@ -750,7 +761,7 @@ begin
|
||||
if (WarningCount = 0) then
|
||||
begin
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sCheckDuplicateOriginals]));
|
||||
ErrorLog.Add(Format(sErrorsByTest,[sShortCheckDuplicateOriginals]));
|
||||
ErrorLog.Add(ShortMasterName);
|
||||
ErrorLog.Add(Divider);
|
||||
ErrorLog.Add('');
|
||||
|
Loading…
Reference in New Issue
Block a user