Converter: Improve localization. Issue #26498.

git-svn-id: trunk@46405 -
This commit is contained in:
juha 2014-10-02 15:10:29 +00:00
parent f9f6d92be7
commit 3e7bb391dc
5 changed files with 45 additions and 34 deletions

View File

@ -264,8 +264,7 @@ begin
SrcCache.MainScanner:=CodeTool.Scanner;
SrcCache.Replace(gtNone, gtNone, NamePos.StartPos, NamePos.EndPos, DiskNm);
if not SrcCache.Apply then exit;
fSettings.AddLogLine(Format('Fixed unit name from %s to %s.',
[UnitNm, DiskNm]));
fSettings.AddLogLine(Format(lisConvFixedUnitName, [UnitNm, DiskNm]));
end;
end;
end;
@ -432,16 +431,15 @@ var
Inc(i); // Get the number after '$'
xLen:=i-xStart;
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.
if xNum < 1 then
raise EDelphiConverterError.Create(
'Replacement function parameter number should be >= 1: '+ aStr);
raise EDelphiConverterError.Create(Format(lisConvReplFuncParameterNum, [aStr]));
ReplacementParams.Add(TReplacementParam.Create(xNum, xLen, xStart));
end;
end;
if HasBracket and (aStr[i]<>')') then
raise EDelphiConverterError.Create('")" is missing from replacement function: '+ aStr);
raise EDelphiConverterError.Create(Format(lisConvBracketMissingFromReplFunc, [aStr]));
Result:=i+1;
end;
@ -508,7 +506,7 @@ begin
// Separate function body
NewFunc:=NewFunc+FuncInfo.InclEmptyBrackets+FuncInfo.InclSemiColon;
if fCTLink.fSettings.FuncReplaceComment then
NewFunc:=NewFunc+' { *Converted from '+FuncInfo.FuncName+'* }';
NewFunc:=NewFunc+Format(lisConvConvertedFrom, [FuncInfo.FuncName]);
Comment:=GetComment(FuncInfo.ReplFunc, PossibleCommentPos);
if Comment<>'' then // Possible comment from the configuration
NewFunc:=NewFunc+' { ' +Comment+' }';
@ -520,7 +518,7 @@ begin
fCTLink.ResetMainScanner;
if not fCTLink.SrcCache.Replace(gtNone, gtNone,
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.
if Assigned(AddUnitEvent) and (FuncInfo.UnitName<>'') then
AddUnitEvent(FuncInfo.UnitName);
@ -624,7 +622,7 @@ var
break;
end;
if not AtomIsChar(',') then
raise EDelphiConverterError.Create('Bracket not found');
raise EDelphiConverterError.Create(lisConvBracketNotFound);
ReadNextAtom;
end;
end

View File

@ -678,8 +678,8 @@ begin
LfmFixer.ObjectsMustExist:=true;
if LfmFixer.ConvertAndRepair<>mrOK then begin
LazarusIDE.DoJumpToCompilerMessage(true);
fOwnerConverter.fErrorMsg:='Problems when repairing form file '
+ChangeFileExt(fOrigUnitFilename, '.lfm');
fOwnerConverter.fErrorMsg:=Format(lisConvProblemsRepairingFormFile,
[ChangeFileExt(fOrigUnitFilename, '.lfm')]);
exit(mrAbort);
end;
finally
@ -745,8 +745,8 @@ begin
Result:=mrOK;
// Abort the whole conversion.
mrAbort:
fOwnerConverter.fErrorMsg:='User selected to end conversion with file '
+fOrigUnitFilename;
fOwnerConverter.fErrorMsg:=Format(lisConvUserSelectedToEndConversion,
[fOrigUnitFilename]);
end;
until not TryAgain;
end;
@ -772,7 +772,7 @@ begin
if CodeTool.FixIncludeFilenames(Code,SrcCache,FoundIncludeFiles,MissingIncludeFilesCodeXYPos)
then begin
if Assigned(FoundIncludeFiles) then begin
Msg:='Repairing include files : ';
Msg:=lisConvRepairingIncludeFiles;
for i:=0 to FoundIncludeFiles.Count-1 do begin
fSettings.MaybeBackupFile(FoundIncludeFiles[i]);
s:=CreateRelativePath(FoundIncludeFiles[i], fSettings.MainPath);
@ -792,8 +792,7 @@ begin
fSettings.AddLogLine(Msg);
end;
end;
fErrorMsg:='Problems when fixing include files in file '
+fOrigUnitFilename;
fErrorMsg:=Format(lisConvProblemsFixingIncludeFile, [fOrigUnitFilename]);
Result:=mrCancel;
end;
finally
@ -812,8 +811,8 @@ begin
mtWarning, [mrIgnore, lisIgnoreAndContinue, mrAbort], 0);
case Result of
mrIgnore : Result:=mrOK;
mrAbort : fOwnerConverter.fErrorMsg:='User selected to end conversion with file '
+fOrigUnitFilename;
mrAbort : fOwnerConverter.fErrorMsg:=Format(lisConvUserSelectedToEndConversion,
[fOrigUnitFilename]);
end;
end;
end;
@ -983,9 +982,7 @@ var
s: string;
begin
if CompareFileExt(fSettings.MainFilename,'.dproj',false)=0 then begin
fErrorMsg:=
'.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.';
fErrorMsg := lisConvDprojFileNotSupportedYet;
Exit(mrCancel);
end;
// Start scanning unit files one level above project path. The GUI will appear
@ -1378,7 +1375,7 @@ begin
if not DeleteFileUTF8(s) then
exit(mrCancel);
//fFilesToDelete.Delete(i);
fSettings.AddLogLine(Format('Deleted file %s',[s]));
fSettings.AddLogLine(Format(lisConvDeletedFile,[s]));
end;
end;
Result:=mrOK;
@ -1595,8 +1592,7 @@ begin
FoundUnits, MisUnits, NormalUnits) then
begin
LazarusIDE.DoJumpToCodeToolBossError;
fErrorMsg:='Problems when trying to find all units from project file '
+fSettings.MainFilename;
fErrorMsg:=Format(lisConvProblemsFindingAllUnits, [fSettings.MainFilename]);
exit(mrCancel);
end;
try // Add all units to the project
@ -1824,7 +1820,7 @@ begin
Format(lisConvDelphiThereIsAlreadyAPackageWithTheNamePleaseCloseThisPa,
[PkgName, LineEnding]), mtError, [mbAbort], 0);
PackageEditingInterface.DoOpenPackageFile(LazPackage.Filename,[pofAddToRecent],true);
fErrorMsg:='Stopped because there already is a package with the same name';
fErrorMsg:=lisConvStoppedBecauseThereIsPackage;
exit(mrAbort);
end else begin
Result:=mrOK;
@ -1881,8 +1877,7 @@ begin
if CodeToolBoss.HasInterfaceRegisterProc(CodeBuffer, HasRegisterProc) then
if HasRegisterProc then begin
Include(Flags, pffHasRegisterProc);
fSettings.AddLogLine(Format('Adding flag for "Register" procedure in unit %s.',
[PureUnitName]));
fSettings.AddLogLine(Format(lisConvAddingFlagForRegister, [PureUnitName]));
end;
// Add new unit to package
LazPackage.AddFile(AFileName, PureUnitName, pftUnit, Flags, cpNormal);
@ -1905,8 +1900,7 @@ begin
FoundUnits, MisUnits, NormalUnits) then
begin
LazarusIDE.DoJumpToCodeToolBossError;
fErrorMsg:='Problems when trying to find all units from package file '
+fSettings.MainFilename;
fErrorMsg:=Format(lisConvProblemsFindingAllUnits, [fSettings.MainFilename]);
exit(mrCancel);
end;
try

View File

@ -797,8 +797,7 @@ begin
end;
function TConvertSettings.AddLogLine(
const ALine: string; Urgency: TMessageLineUrgency
): integer;
const ALine: string; Urgency: TMessageLineUrgency): integer;
begin
IDEMessagesWindow.AddCustomMessage(Urgency,aLine); // Show in message window
Result:=fLog.Add(MessageLineUrgencyNames[Urgency]+': '+ALine);// and store for log.
@ -813,8 +812,8 @@ begin
Code:=CodeToolBoss.CreateFile(aFilename);
Code.Assign(fLog);
Result:=SaveCodeBuffer(Code)=mrOk;
if Result then
IDEMessagesWindow.AddCustomMessage(mluHint,'This log was saved to '+aFilename); // Show in message window
if Result then // Show in message window
IDEMessagesWindow.AddCustomMessage(mluHint,Format(lisConvThisLogWasSaved, [aFilename]));
end;
function TConvertSettings.GetBackupPath: String;

View File

@ -776,7 +776,7 @@ procedure TUsedUnitsTool.AddUnitIfNeeded(aUnitName: string);
begin
if not HasUnit(aUnitName) then begin
fMainUsedUnits.fUnitsToAdd.Add(aUnitName);
fCTLink.Settings.AddLogLine('Added unit '+aUnitName+ ' to uses section');
fCTLink.Settings.AddLogLine(Format(lisConvAddedUnitToUsesSection, [aUnitName]));
MaybeOpenPackage(aUnitName);
end;
end;

View File

@ -640,6 +640,26 @@ resourcestring
lisConvTopOff = 'Top offset';
lisConvLeftOff = 'Left offset';
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';
lisScanParentDir = 'Scanning parent directory';
lisReplacement = 'Replacement';