mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 07:20:01 +02:00
Converter: Improve localization. Issue #26498.
git-svn-id: trunk@46405 -
This commit is contained in:
parent
f9f6d92be7
commit
3e7bb391dc
@ -264,8 +264,7 @@ begin
|
|||||||
SrcCache.MainScanner:=CodeTool.Scanner;
|
SrcCache.MainScanner:=CodeTool.Scanner;
|
||||||
SrcCache.Replace(gtNone, gtNone, NamePos.StartPos, NamePos.EndPos, DiskNm);
|
SrcCache.Replace(gtNone, gtNone, NamePos.StartPos, NamePos.EndPos, DiskNm);
|
||||||
if not SrcCache.Apply then exit;
|
if not SrcCache.Apply then exit;
|
||||||
fSettings.AddLogLine(Format('Fixed unit name from %s to %s.',
|
fSettings.AddLogLine(Format(lisConvFixedUnitName, [UnitNm, DiskNm]));
|
||||||
[UnitNm, DiskNm]));
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -432,16 +431,15 @@ var
|
|||||||
Inc(i); // Get the number after '$'
|
Inc(i); // Get the number after '$'
|
||||||
xLen:=i-xStart;
|
xLen:=i-xStart;
|
||||||
if xLen<2 then
|
if xLen<2 then
|
||||||
raise EDelphiConverterError.Create('"$" should be followed by a number: '+ aStr);
|
raise EDelphiConverterError.Create(Format(lisConvShouldBeFollowedByNumber, [aStr]));
|
||||||
xNum:=StrToInt(copy(aStr, xStart+1, xLen-1)); // Leave out '$', convert number.
|
xNum:=StrToInt(copy(aStr, xStart+1, xLen-1)); // Leave out '$', convert number.
|
||||||
if xNum < 1 then
|
if xNum < 1 then
|
||||||
raise EDelphiConverterError.Create(
|
raise EDelphiConverterError.Create(Format(lisConvReplFuncParameterNum, [aStr]));
|
||||||
'Replacement function parameter number should be >= 1: '+ aStr);
|
|
||||||
ReplacementParams.Add(TReplacementParam.Create(xNum, xLen, xStart));
|
ReplacementParams.Add(TReplacementParam.Create(xNum, xLen, xStart));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if HasBracket and (aStr[i]<>')') then
|
if HasBracket and (aStr[i]<>')') then
|
||||||
raise EDelphiConverterError.Create('")" is missing from replacement function: '+ aStr);
|
raise EDelphiConverterError.Create(Format(lisConvBracketMissingFromReplFunc, [aStr]));
|
||||||
Result:=i+1;
|
Result:=i+1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -508,7 +506,7 @@ begin
|
|||||||
// Separate function body
|
// Separate function body
|
||||||
NewFunc:=NewFunc+FuncInfo.InclEmptyBrackets+FuncInfo.InclSemiColon;
|
NewFunc:=NewFunc+FuncInfo.InclEmptyBrackets+FuncInfo.InclSemiColon;
|
||||||
if fCTLink.fSettings.FuncReplaceComment then
|
if fCTLink.fSettings.FuncReplaceComment then
|
||||||
NewFunc:=NewFunc+' { *Converted from '+FuncInfo.FuncName+'* }';
|
NewFunc:=NewFunc+Format(lisConvConvertedFrom, [FuncInfo.FuncName]);
|
||||||
Comment:=GetComment(FuncInfo.ReplFunc, PossibleCommentPos);
|
Comment:=GetComment(FuncInfo.ReplFunc, PossibleCommentPos);
|
||||||
if Comment<>'' then // Possible comment from the configuration
|
if Comment<>'' then // Possible comment from the configuration
|
||||||
NewFunc:=NewFunc+' { ' +Comment+' }';
|
NewFunc:=NewFunc+' { ' +Comment+' }';
|
||||||
@ -520,7 +518,7 @@ begin
|
|||||||
fCTLink.ResetMainScanner;
|
fCTLink.ResetMainScanner;
|
||||||
if not fCTLink.SrcCache.Replace(gtNone, gtNone,
|
if not fCTLink.SrcCache.Replace(gtNone, gtNone,
|
||||||
FuncInfo.StartPos, FuncInfo.EndPos, NewFunc) then exit;
|
FuncInfo.StartPos, FuncInfo.EndPos, NewFunc) then exit;
|
||||||
fCTLink.fSettings.AddLogLine('Replaced call '+s+' with '+NewFunc);
|
fCTLink.fSettings.AddLogLine(Format(lisConvReplacedCall, [s, NewFunc]));
|
||||||
// Add the required unit name to uses section if needed.
|
// Add the required unit name to uses section if needed.
|
||||||
if Assigned(AddUnitEvent) and (FuncInfo.UnitName<>'') then
|
if Assigned(AddUnitEvent) and (FuncInfo.UnitName<>'') then
|
||||||
AddUnitEvent(FuncInfo.UnitName);
|
AddUnitEvent(FuncInfo.UnitName);
|
||||||
@ -624,7 +622,7 @@ var
|
|||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
if not AtomIsChar(',') then
|
if not AtomIsChar(',') then
|
||||||
raise EDelphiConverterError.Create('Bracket not found');
|
raise EDelphiConverterError.Create(lisConvBracketNotFound);
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
@ -678,8 +678,8 @@ begin
|
|||||||
LfmFixer.ObjectsMustExist:=true;
|
LfmFixer.ObjectsMustExist:=true;
|
||||||
if LfmFixer.ConvertAndRepair<>mrOK then begin
|
if LfmFixer.ConvertAndRepair<>mrOK then begin
|
||||||
LazarusIDE.DoJumpToCompilerMessage(true);
|
LazarusIDE.DoJumpToCompilerMessage(true);
|
||||||
fOwnerConverter.fErrorMsg:='Problems when repairing form file '
|
fOwnerConverter.fErrorMsg:=Format(lisConvProblemsRepairingFormFile,
|
||||||
+ChangeFileExt(fOrigUnitFilename, '.lfm');
|
[ChangeFileExt(fOrigUnitFilename, '.lfm')]);
|
||||||
exit(mrAbort);
|
exit(mrAbort);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -745,8 +745,8 @@ begin
|
|||||||
Result:=mrOK;
|
Result:=mrOK;
|
||||||
// Abort the whole conversion.
|
// Abort the whole conversion.
|
||||||
mrAbort:
|
mrAbort:
|
||||||
fOwnerConverter.fErrorMsg:='User selected to end conversion with file '
|
fOwnerConverter.fErrorMsg:=Format(lisConvUserSelectedToEndConversion,
|
||||||
+fOrigUnitFilename;
|
[fOrigUnitFilename]);
|
||||||
end;
|
end;
|
||||||
until not TryAgain;
|
until not TryAgain;
|
||||||
end;
|
end;
|
||||||
@ -772,7 +772,7 @@ begin
|
|||||||
if CodeTool.FixIncludeFilenames(Code,SrcCache,FoundIncludeFiles,MissingIncludeFilesCodeXYPos)
|
if CodeTool.FixIncludeFilenames(Code,SrcCache,FoundIncludeFiles,MissingIncludeFilesCodeXYPos)
|
||||||
then begin
|
then begin
|
||||||
if Assigned(FoundIncludeFiles) then begin
|
if Assigned(FoundIncludeFiles) then begin
|
||||||
Msg:='Repairing include files : ';
|
Msg:=lisConvRepairingIncludeFiles;
|
||||||
for i:=0 to FoundIncludeFiles.Count-1 do begin
|
for i:=0 to FoundIncludeFiles.Count-1 do begin
|
||||||
fSettings.MaybeBackupFile(FoundIncludeFiles[i]);
|
fSettings.MaybeBackupFile(FoundIncludeFiles[i]);
|
||||||
s:=CreateRelativePath(FoundIncludeFiles[i], fSettings.MainPath);
|
s:=CreateRelativePath(FoundIncludeFiles[i], fSettings.MainPath);
|
||||||
@ -792,8 +792,7 @@ begin
|
|||||||
fSettings.AddLogLine(Msg);
|
fSettings.AddLogLine(Msg);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
fErrorMsg:='Problems when fixing include files in file '
|
fErrorMsg:=Format(lisConvProblemsFixingIncludeFile, [fOrigUnitFilename]);
|
||||||
+fOrigUnitFilename;
|
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -812,8 +811,8 @@ begin
|
|||||||
mtWarning, [mrIgnore, lisIgnoreAndContinue, mrAbort], 0);
|
mtWarning, [mrIgnore, lisIgnoreAndContinue, mrAbort], 0);
|
||||||
case Result of
|
case Result of
|
||||||
mrIgnore : Result:=mrOK;
|
mrIgnore : Result:=mrOK;
|
||||||
mrAbort : fOwnerConverter.fErrorMsg:='User selected to end conversion with file '
|
mrAbort : fOwnerConverter.fErrorMsg:=Format(lisConvUserSelectedToEndConversion,
|
||||||
+fOrigUnitFilename;
|
[fOrigUnitFilename]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -983,9 +982,7 @@ var
|
|||||||
s: string;
|
s: string;
|
||||||
begin
|
begin
|
||||||
if CompareFileExt(fSettings.MainFilename,'.dproj',false)=0 then begin
|
if CompareFileExt(fSettings.MainFilename,'.dproj',false)=0 then begin
|
||||||
fErrorMsg:=
|
fErrorMsg := lisConvDprojFileNotSupportedYet;
|
||||||
'.dproj file is not supported yet. The file is used by Delphi 2007 and newer.'+
|
|
||||||
' Please select a .dpr file for projects or .dpk file for packages.';
|
|
||||||
Exit(mrCancel);
|
Exit(mrCancel);
|
||||||
end;
|
end;
|
||||||
// Start scanning unit files one level above project path. The GUI will appear
|
// Start scanning unit files one level above project path. The GUI will appear
|
||||||
@ -1378,7 +1375,7 @@ begin
|
|||||||
if not DeleteFileUTF8(s) then
|
if not DeleteFileUTF8(s) then
|
||||||
exit(mrCancel);
|
exit(mrCancel);
|
||||||
//fFilesToDelete.Delete(i);
|
//fFilesToDelete.Delete(i);
|
||||||
fSettings.AddLogLine(Format('Deleted file %s',[s]));
|
fSettings.AddLogLine(Format(lisConvDeletedFile,[s]));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result:=mrOK;
|
Result:=mrOK;
|
||||||
@ -1595,8 +1592,7 @@ begin
|
|||||||
FoundUnits, MisUnits, NormalUnits) then
|
FoundUnits, MisUnits, NormalUnits) then
|
||||||
begin
|
begin
|
||||||
LazarusIDE.DoJumpToCodeToolBossError;
|
LazarusIDE.DoJumpToCodeToolBossError;
|
||||||
fErrorMsg:='Problems when trying to find all units from project file '
|
fErrorMsg:=Format(lisConvProblemsFindingAllUnits, [fSettings.MainFilename]);
|
||||||
+fSettings.MainFilename;
|
|
||||||
exit(mrCancel);
|
exit(mrCancel);
|
||||||
end;
|
end;
|
||||||
try // Add all units to the project
|
try // Add all units to the project
|
||||||
@ -1824,7 +1820,7 @@ begin
|
|||||||
Format(lisConvDelphiThereIsAlreadyAPackageWithTheNamePleaseCloseThisPa,
|
Format(lisConvDelphiThereIsAlreadyAPackageWithTheNamePleaseCloseThisPa,
|
||||||
[PkgName, LineEnding]), mtError, [mbAbort], 0);
|
[PkgName, LineEnding]), mtError, [mbAbort], 0);
|
||||||
PackageEditingInterface.DoOpenPackageFile(LazPackage.Filename,[pofAddToRecent],true);
|
PackageEditingInterface.DoOpenPackageFile(LazPackage.Filename,[pofAddToRecent],true);
|
||||||
fErrorMsg:='Stopped because there already is a package with the same name';
|
fErrorMsg:=lisConvStoppedBecauseThereIsPackage;
|
||||||
exit(mrAbort);
|
exit(mrAbort);
|
||||||
end else begin
|
end else begin
|
||||||
Result:=mrOK;
|
Result:=mrOK;
|
||||||
@ -1881,8 +1877,7 @@ begin
|
|||||||
if CodeToolBoss.HasInterfaceRegisterProc(CodeBuffer, HasRegisterProc) then
|
if CodeToolBoss.HasInterfaceRegisterProc(CodeBuffer, HasRegisterProc) then
|
||||||
if HasRegisterProc then begin
|
if HasRegisterProc then begin
|
||||||
Include(Flags, pffHasRegisterProc);
|
Include(Flags, pffHasRegisterProc);
|
||||||
fSettings.AddLogLine(Format('Adding flag for "Register" procedure in unit %s.',
|
fSettings.AddLogLine(Format(lisConvAddingFlagForRegister, [PureUnitName]));
|
||||||
[PureUnitName]));
|
|
||||||
end;
|
end;
|
||||||
// Add new unit to package
|
// Add new unit to package
|
||||||
LazPackage.AddFile(AFileName, PureUnitName, pftUnit, Flags, cpNormal);
|
LazPackage.AddFile(AFileName, PureUnitName, pftUnit, Flags, cpNormal);
|
||||||
@ -1905,8 +1900,7 @@ begin
|
|||||||
FoundUnits, MisUnits, NormalUnits) then
|
FoundUnits, MisUnits, NormalUnits) then
|
||||||
begin
|
begin
|
||||||
LazarusIDE.DoJumpToCodeToolBossError;
|
LazarusIDE.DoJumpToCodeToolBossError;
|
||||||
fErrorMsg:='Problems when trying to find all units from package file '
|
fErrorMsg:=Format(lisConvProblemsFindingAllUnits, [fSettings.MainFilename]);
|
||||||
+fSettings.MainFilename;
|
|
||||||
exit(mrCancel);
|
exit(mrCancel);
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
|
@ -797,8 +797,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertSettings.AddLogLine(
|
function TConvertSettings.AddLogLine(
|
||||||
const ALine: string; Urgency: TMessageLineUrgency
|
const ALine: string; Urgency: TMessageLineUrgency): integer;
|
||||||
): integer;
|
|
||||||
begin
|
begin
|
||||||
IDEMessagesWindow.AddCustomMessage(Urgency,aLine); // Show in message window
|
IDEMessagesWindow.AddCustomMessage(Urgency,aLine); // Show in message window
|
||||||
Result:=fLog.Add(MessageLineUrgencyNames[Urgency]+': '+ALine);// and store for log.
|
Result:=fLog.Add(MessageLineUrgencyNames[Urgency]+': '+ALine);// and store for log.
|
||||||
@ -813,8 +812,8 @@ begin
|
|||||||
Code:=CodeToolBoss.CreateFile(aFilename);
|
Code:=CodeToolBoss.CreateFile(aFilename);
|
||||||
Code.Assign(fLog);
|
Code.Assign(fLog);
|
||||||
Result:=SaveCodeBuffer(Code)=mrOk;
|
Result:=SaveCodeBuffer(Code)=mrOk;
|
||||||
if Result then
|
if Result then // Show in message window
|
||||||
IDEMessagesWindow.AddCustomMessage(mluHint,'This log was saved to '+aFilename); // Show in message window
|
IDEMessagesWindow.AddCustomMessage(mluHint,Format(lisConvThisLogWasSaved, [aFilename]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertSettings.GetBackupPath: String;
|
function TConvertSettings.GetBackupPath: String;
|
||||||
|
@ -776,7 +776,7 @@ procedure TUsedUnitsTool.AddUnitIfNeeded(aUnitName: string);
|
|||||||
begin
|
begin
|
||||||
if not HasUnit(aUnitName) then begin
|
if not HasUnit(aUnitName) then begin
|
||||||
fMainUsedUnits.fUnitsToAdd.Add(aUnitName);
|
fMainUsedUnits.fUnitsToAdd.Add(aUnitName);
|
||||||
fCTLink.Settings.AddLogLine('Added unit '+aUnitName+ ' to uses section');
|
fCTLink.Settings.AddLogLine(Format(lisConvAddedUnitToUsesSection, [aUnitName]));
|
||||||
MaybeOpenPackage(aUnitName);
|
MaybeOpenPackage(aUnitName);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -640,6 +640,26 @@ resourcestring
|
|||||||
lisConvTopOff = 'Top offset';
|
lisConvTopOff = 'Top offset';
|
||||||
lisConvLeftOff = 'Left offset';
|
lisConvLeftOff = 'Left offset';
|
||||||
lisConvDelphiFunc = 'Delphi Function';
|
lisConvDelphiFunc = 'Delphi Function';
|
||||||
|
lisConvAddedUnitToUsesSection = 'Added unit %s to uses section';
|
||||||
|
lisConvAddingFlagForRegister = 'Adding flag for "Register" procedure in unit %s.';
|
||||||
|
lisConvDeletedFile = 'Deleted file %s';
|
||||||
|
lisConvBracketNotFound = 'Bracket not found';
|
||||||
|
lisConvDprojFileNotSupportedYet =
|
||||||
|
'.dproj file is not supported yet. The file is used by Delphi 2007 and newer.'+
|
||||||
|
' Please select a .dpr file for projects or .dpk file for packages.';
|
||||||
|
lisConvRepairingIncludeFiles = 'Repairing include files : ';
|
||||||
|
lisConvUserSelectedToEndConversion = 'User selected to end conversion with file %s';
|
||||||
|
lisConvFixedUnitName = 'Fixed unit name from %s to %s.';
|
||||||
|
lisConvShouldBeFollowedByNumber = '"$" should be followed by a number: %s';
|
||||||
|
lisConvReplacedCall = 'Replaced call %s with %s';
|
||||||
|
lisConvReplFuncParameterNum = 'Replacement function parameter number should be >= 1: %s';
|
||||||
|
lisConvBracketMissingFromReplFunc = '")" is missing from replacement function: %s';
|
||||||
|
lisConvProblemsFindingAllUnits = 'Problems when trying to find all units from project file %s';
|
||||||
|
lisConvProblemsRepairingFormFile = 'Problems when repairing form file %s';
|
||||||
|
lisConvProblemsFixingIncludeFile = 'Problems when fixing include files in file %s';
|
||||||
|
lisConvStoppedBecauseThereIsPackage = 'Stopped because there already is a package with the same name';
|
||||||
|
lisConvConvertedFrom = ' { *Converted from %s* }';
|
||||||
|
lisConvThisLogWasSaved = 'This log was saved to %s';
|
||||||
lisScanning = 'Scanning';
|
lisScanning = 'Scanning';
|
||||||
lisScanParentDir = 'Scanning parent directory';
|
lisScanParentDir = 'Scanning parent directory';
|
||||||
lisReplacement = 'Replacement';
|
lisReplacement = 'Replacement';
|
||||||
|
Loading…
Reference in New Issue
Block a user