simplewebservergui: resourcestrings

This commit is contained in:
mattias 2022-04-09 14:22:29 +02:00
parent ec86caf1ff
commit 2826adac9b
5 changed files with 220 additions and 27 deletions

View File

@ -684,15 +684,15 @@ begin
CompOpts:=AProject.LazCompilerOptions; CompOpts:=AProject.LazCompilerOptions;
TargetFilename:=AppendPathDelim(WebDir)+'ServiceWorker'; TargetFilename:=AppendPathDelim(WebDir)+'ServiceWorker';
// save ServiceWorker.lpr // save ServiceWorker.lpr and open it in source editor
if not InteractiveSaveFile(ServiceWorkerLPR) then exit; if not InteractiveSaveFile(ServiceWorkerLPR) then exit;
LazarusIDE.DoOpenEditorFile(ServiceWorkerLPR,-1,-1, LazarusIDE.DoOpenEditorFile(ServiceWorkerLPR,-1,-1,
[ofProjectLoading,ofRegularFile]); [ofProjectLoading,ofRegularFile]);
// save ServiceWorker.lpi // save ServiceWorker.lpi
if LazarusIDE.DoSaveProject([sfQuietUnitCheck])<>mrOk then exit; if LazarusIDE.DoSaveProject([sfQuietUnitCheck])<>mrOk then exit;
LazarusIDE.DoCloseEditorFile(ServiceWorkerLPR,[cfQuiet,cfProjectClosing]);
// delete ServiceWorker.lpr from project // delete ServiceWorker.lpr from project
LazarusIDE.DoCloseEditorFile(ServiceWorkerLPR,[cfQuiet,cfProjectClosing]);
if AProject.MainFileID<>0 then if AProject.MainFileID<>0 then
raise Exception.Create('20220405231537'); raise Exception.Create('20220405231537');
AProject.MainFileID:=-1; AProject.MainFileID:=-1;

View File

@ -1,6 +1,49 @@
msgid "" msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8" msgstr "Content-Type: text/plain; charset=UTF-8"
#: simplewebsrvstrconsts.rsswbindingofsocketfailed
msgid "Binding of socket failed"
msgstr ""
#: simplewebsrvstrconsts.rsswdirectorynotfound
msgid "Directory not found"
msgstr ""
#: simplewebsrvstrconsts.rsswerror
msgid "Error"
msgstr ""
#: simplewebsrvstrconsts.rsswerrorcreatingdirectory
msgid "Error creating directory"
msgstr ""
#: simplewebsrvstrconsts.rsswerrorwriting
#, object-pascal-format
msgid "Error writing \"%s\""
msgstr ""
#: simplewebsrvstrconsts.rsswfilenotfound
#, object-pascal-format
msgid "File not found: \"%s\""
msgstr ""
#: simplewebsrvstrconsts.rsswkillpid
#, object-pascal-format
msgid "Kill PID %s"
msgstr ""
#: simplewebsrvstrconsts.rsswkillprocess
msgid "Kill process?"
msgstr ""
#: simplewebsrvstrconsts.rsswmissinglocaldirectory
msgid "Missing local directory"
msgstr ""
#: simplewebsrvstrconsts.rsswmissingserverexecutable
msgid "Missing server executable"
msgstr ""
#: simplewebsrvstrconsts.rsswsaddress #: simplewebsrvstrconsts.rsswsaddress
msgid "Address" msgid "Address"
msgstr "" msgstr ""
@ -9,6 +52,33 @@ msgstr ""
msgid "Bind Any" msgid "Bind Any"
msgstr "" msgstr ""
#: simplewebsrvstrconsts.rsswserverdirectorynotfound
#, object-pascal-format
msgid "Server directory \"%s\" not found."
msgstr ""
#: simplewebsrvstrconsts.rsswserverexecutablenotfoundinpath
#, object-pascal-format
msgid "Server executable \"%s\" not found in PATH."
msgstr ""
#: simplewebsrvstrconsts.rsswserverexeisnotexecutable
#, object-pascal-format
msgid "Server exe is not executable: \"%s\""
msgstr ""
#: simplewebsrvstrconsts.rsswsimplewebserveraddress
msgid "Simple Web Server Address"
msgstr ""
#: simplewebsrvstrconsts.rsswsimplewebserverexecutable
msgid "Simple Web Server Executable"
msgstr ""
#: simplewebsrvstrconsts.rsswsimplewebserverport
msgid "Simple Web Server Port"
msgstr ""
#: simplewebsrvstrconsts.rsswspathofcompileserver #: simplewebsrvstrconsts.rsswspathofcompileserver
msgid "Path of compileserver" msgid "Path of compileserver"
msgstr "" msgstr ""
@ -25,3 +95,16 @@ msgstr ""
msgid "User" msgid "User"
msgstr "" msgstr ""
#: simplewebsrvstrconsts.rsswthefollowingprocessalreadylistens
msgid "The following process already listens:"
msgstr ""
#: simplewebsrvstrconsts.rsswtryanotherport
msgid "Try another port"
msgstr ""
#: simplewebsrvstrconsts.rsswwrongcompileserverexe
#, object-pascal-format
msgid "Wrong compileserver exe: %s"
msgstr ""

View File

@ -11,6 +11,49 @@ msgstr ""
"Language: ru\n" "Language: ru\n"
"X-Generator: Poedit 2.4.3\n" "X-Generator: Poedit 2.4.3\n"
#: simplewebsrvstrconsts.rsswbindingofsocketfailed
msgid "Binding of socket failed"
msgstr ""
#: simplewebsrvstrconsts.rsswdirectorynotfound
msgid "Directory not found"
msgstr ""
#: simplewebsrvstrconsts.rsswerror
msgid "Error"
msgstr ""
#: simplewebsrvstrconsts.rsswerrorcreatingdirectory
msgid "Error creating directory"
msgstr ""
#: simplewebsrvstrconsts.rsswerrorwriting
#, object-pascal-format
msgid "Error writing \"%s\""
msgstr ""
#: simplewebsrvstrconsts.rsswfilenotfound
#, object-pascal-format
msgid "File not found: \"%s\""
msgstr ""
#: simplewebsrvstrconsts.rsswkillpid
#, object-pascal-format
msgid "Kill PID %s"
msgstr ""
#: simplewebsrvstrconsts.rsswkillprocess
msgid "Kill process?"
msgstr ""
#: simplewebsrvstrconsts.rsswmissinglocaldirectory
msgid "Missing local directory"
msgstr ""
#: simplewebsrvstrconsts.rsswmissingserverexecutable
msgid "Missing server executable"
msgstr ""
#: simplewebsrvstrconsts.rsswsaddress #: simplewebsrvstrconsts.rsswsaddress
msgid "Address" msgid "Address"
msgstr "Адрес" msgstr "Адрес"
@ -19,6 +62,33 @@ msgstr "Адрес"
msgid "Bind Any" msgid "Bind Any"
msgstr "Привязать все" msgstr "Привязать все"
#: simplewebsrvstrconsts.rsswserverdirectorynotfound
#, object-pascal-format
msgid "Server directory \"%s\" not found."
msgstr ""
#: simplewebsrvstrconsts.rsswserverexecutablenotfoundinpath
#, object-pascal-format
msgid "Server executable \"%s\" not found in PATH."
msgstr ""
#: simplewebsrvstrconsts.rsswserverexeisnotexecutable
#, object-pascal-format
msgid "Server exe is not executable: \"%s\""
msgstr ""
#: simplewebsrvstrconsts.rsswsimplewebserveraddress
msgid "Simple Web Server Address"
msgstr ""
#: simplewebsrvstrconsts.rsswsimplewebserverexecutable
msgid "Simple Web Server Executable"
msgstr ""
#: simplewebsrvstrconsts.rsswsimplewebserverport
msgid "Simple Web Server Port"
msgstr ""
#: simplewebsrvstrconsts.rsswspathofcompileserver #: simplewebsrvstrconsts.rsswspathofcompileserver
msgid "Path of compileserver" msgid "Path of compileserver"
msgstr "Путь к серверу компиляции" msgstr "Путь к серверу компиляции"
@ -35,3 +105,16 @@ msgstr "Простой веб-сервер"
msgid "User" msgid "User"
msgstr "Пользователь" msgstr "Пользователь"
#: simplewebsrvstrconsts.rsswthefollowingprocessalreadylistens
msgid "The following process already listens:"
msgstr ""
#: simplewebsrvstrconsts.rsswtryanotherport
msgid "Try another port"
msgstr ""
#: simplewebsrvstrconsts.rsswwrongcompileserverexe
#, object-pascal-format
msgid "Wrong compileserver exe: %s"
msgstr ""

View File

@ -31,7 +31,7 @@ Working:
ToDos: ToDos:
- log with time and port - log with time and port
- ide macro SWSExe param: 'resolved', 'base', 'used' and '' - ide macro SWSExe param: 'base', 'used' and ''
- Windows: add GetUDPTable2 - Windows: add GetUDPTable2
- resourcestrings - resourcestrings
- SSL - SSL
@ -52,7 +52,7 @@ uses
Forms, Dialogs, Controls, Forms, Dialogs, Controls,
// IDEIntf // IDEIntf
IDEDialogs, IDEMsgIntf, LazIDEIntf, IDEExternToolIntf, MacroIntf, IDEDialogs, IDEMsgIntf, LazIDEIntf, IDEExternToolIntf, MacroIntf,
MacroDefIntf, SimpleWebSrvUtils, SimpleWebSrvOptions; MacroDefIntf, SimpleWebSrvUtils, SimpleWebSrvOptions, SimpleWebSrvStrConsts;
type type
ESimpleWebServerException = class(Exception) ESimpleWebServerException = class(Exception)
@ -450,22 +450,25 @@ begin
IPAddr:=StrToHostAddr(MainSrvAddr); IPAddr:=StrToHostAddr(MainSrvAddr);
if not FUtility.FindProcessListeningOnPort(IPAddr,MainSrvPort,aProcDescription,aPID) then if not FUtility.FindProcessListeningOnPort(IPAddr,MainSrvPort,aProcDescription,aPID) then
begin begin
IDEMessageDialog('Error', IDEMessageDialog(rsSWError,
ViewCaption+':'+sLineBreak ViewCaption+':'+sLineBreak
+'Binding of socket failed: '+MainSrvAddr+':'+IntToStr(MainSrvPort),mtError,[mbOk]); +rsSWBindingOfSocketFailed+': '+MainSrvAddr+':'+IntToStr(MainSrvPort
), mtError, [mbOk]);
exit; exit;
end; end;
r:=IDEQuestionDialog('Error', r:=IDEQuestionDialog(rsSWError,
ViewCaption+':'+sLineBreak ViewCaption+':'+sLineBreak
+'Binding of socket failed: '+MainSrvAddr+':'+IntToStr(MainSrvPort)+sLineBreak +rsSWBindingOfSocketFailed+': '+MainSrvAddr+':'+IntToStr(MainSrvPort)+
sLineBreak
+sLineBreak +sLineBreak
+'The following process already listens:'+sLineBreak +rsSWTheFollowingProcessAlreadyListens+sLineBreak
+'PID: '+IntToStr(aPID)+sLineBreak +'PID: '+IntToStr(aPID)+sLineBreak
+aProcDescription+sLineBreak +aProcDescription+sLineBreak
+sLineBreak +sLineBreak
+'Kill process?' +rsSWKillProcess
,mtError,[mrYes,'Kill PID '+IntToStr(aPID),mrRetry,'Try another port',mrCancel],''); , mtError, [mrYes, Format(rsSWKillPID, [IntToStr(aPID)]), mrRetry,
rsSWTryAnotherPort, mrCancel], '');
case r of case r of
mrYes: mrYes:
@ -891,7 +894,7 @@ begin
Instance.ErrorDesc:='missing server exe. '+LinePostfix; Instance.ErrorDesc:='missing server exe. '+LinePostfix;
AddIDEMessageInfo('20220127115641',Instance.ErrorDesc); AddIDEMessageInfo('20220127115641',Instance.ErrorDesc);
if Interactive then if Interactive then
ErrDlg('Missing Server Exe','Missing server executable',true); ErrDlg(rsSWError, rsSWMissingServerExecutable, true);
exit; exit;
end; end;
if PathUsed='' then if PathUsed='' then
@ -899,7 +902,7 @@ begin
Instance.ErrorDesc:='missing local directory. '+LinePostfix; Instance.ErrorDesc:='missing local directory. '+LinePostfix;
AddIDEMessageInfo('20220127115738',Instance.ErrorDesc); AddIDEMessageInfo('20220127115738',Instance.ErrorDesc);
if Interactive then if Interactive then
ErrDlg('Missing Local Directory','Missing local directory',false); ErrDlg(rsSWError, rsSWMissingLocalDirectory, false);
exit; exit;
end; end;
@ -911,7 +914,8 @@ begin
Instance.ErrorDesc:='server directory not found "'+PathUsed+'". '+LinePostfix; Instance.ErrorDesc:='server directory not found "'+PathUsed+'". '+LinePostfix;
AddIDEMessageInfo('20220127122933',Instance.ErrorDesc); AddIDEMessageInfo('20220127122933',Instance.ErrorDesc);
if Interactive then if Interactive then
ErrDlg('Missing Server Directory','Server directory "'+PathUsed+'" not found.',false); ErrDlg(rsSWError, Format(rsSWServerDirectoryNotFound, [PathUsed]), false
);
exit; exit;
end; end;
@ -926,7 +930,8 @@ begin
Instance.ErrorDesc:='server exe "'+ExeUsed+'" not found in PATH. '+LinePostfix; Instance.ErrorDesc:='server exe "'+ExeUsed+'" not found in PATH. '+LinePostfix;
AddIDEMessageInfo('20220127115917',Instance.ErrorDesc); AddIDEMessageInfo('20220127115917',Instance.ErrorDesc);
if Interactive then if Interactive then
ErrDlg('Missing Server Exe','Server executable "'+ExeUsed+'" not found in PATH.',true); ErrDlg(rsSWError, Format(rsSWServerExecutableNotFoundInPATH, [ExeUsed]
), true);
exit; exit;
end; end;
ExeUsed:=s; ExeUsed:=s;
@ -939,14 +944,15 @@ begin
begin begin
AddIDEMessageInfo('20220127114637','Error: server exe not found "'+ExeUsed+'"'); AddIDEMessageInfo('20220127114637','Error: server exe not found "'+ExeUsed+'"');
if Interactive then if Interactive then
ErrDlg('Error','File not found: "'+ExeUsed+'"',true); ErrDlg(rsSWError, Format(rsSWFileNotFound, [ExeUsed]), true);
exit; exit;
end; end;
if not FileIsExecutable(ExeUsed) then if not FileIsExecutable(ExeUsed) then
begin begin
AddIDEMessageInfo('20220127121636','Error: server exe not executable "'+ExeUsed+'"'); AddIDEMessageInfo('20220127121636','Error: server exe not executable "'+ExeUsed+'"');
if Interactive then if Interactive then
ErrDlg('Error','Server exe is not executable: "'+ExeUsed+'"',true); ErrDlg(rsSWError, Format(rsSWServerExeIsNotExecutable, [ExeUsed]), true
);
exit; exit;
end; end;
@ -1223,7 +1229,7 @@ begin
debugln(['Error: [TSimpleWebServerController.StartServerInstance] invalid ServerExe="',Options.ServerExe,'". ',ErrMsg]); debugln(['Error: [TSimpleWebServerController.StartServerInstance] invalid ServerExe="',Options.ServerExe,'". ',ErrMsg]);
AddIDEMessageInfo('20220118164525',ErrMsg); AddIDEMessageInfo('20220118164525',ErrMsg);
if Interactive then if Interactive then
ErrDlg('Error','Wrong compileserver exe: '+ErrMsg,true); ErrDlg(rsSWError, Format(rsSWWrongCompileserverExe, [ErrMsg]), true);
exit; exit;
end; end;
@ -1232,9 +1238,9 @@ begin
begin begin
if CreateDirUTF8(PathUsed) then if CreateDirUTF8(PathUsed) then
break; break;
MsgResult:=IDEMessageDialog('Error', MsgResult:=IDEMessageDialog(rsSWError,
ViewCaption+':'+sLineBreak ViewCaption+':'+sLineBreak
+'Error creating directory'+sLineBreak +rsSWErrorCreatingDirectory+sLineBreak
+'"'+PathUsed+'"'+sLineBreak, +'"'+PathUsed+'"'+sLineBreak,
mtError,[mbRetry,mbCancel]); mtError,[mbRetry,mbCancel]);
case MsgResult of case MsgResult of
@ -1265,7 +1271,7 @@ begin
if not DirectoryExists(Loc.Path) then if not DirectoryExists(Loc.Path) then
begin begin
AddIDEMessageInfo('20220118165651','Warn: location "'+Loc.Location+'" directory not found: "'+Loc.Path+'"'); AddIDEMessageInfo('20220118165651','Warn: location "'+Loc.Location+'" directory not found: "'+Loc.Path+'"');
Loc.ErrorDesc:='Directory not found'; Loc.ErrorDesc:=rsSWDirectoryNotFound;
continue; continue;
end else end else
Loc.ErrorDesc:=''; Loc.ErrorDesc:='';
@ -1285,9 +1291,9 @@ begin
AddIDEMessageInfo('20220127123435',FMainSrvInstance.ErrorDesc); AddIDEMessageInfo('20220127123435',FMainSrvInstance.ErrorDesc);
if Interactive then if Interactive then
begin begin
MsgResult:=IDEMessageDialog('Error', MsgResult:=IDEMessageDialog(rsSWError,
ViewCaption+':'+sLineBreak ViewCaption+':'+sLineBreak
+'Error writing "'+IniFilename+'"'+sLineBreak +Format(rsSWErrorWriting, [IniFilename])+sLineBreak
+E.Message, +E.Message,
mtError,[mbRetry,mbCancel]); mtError,[mbRetry,mbCancel]);
case MsgResult of case MsgResult of
@ -1351,7 +1357,7 @@ begin
// already exists // already exists
Result:=Locations[i]; Result:=Locations[i];
if DirNotFound then if DirNotFound then
Result.ErrorDesc:='Directory not found'; Result.ErrorDesc:=rsSWDirectoryNotFound;
if (Result.Enable=Enable) and (Result.Path=ExpPath) and (Result.Origin=Origin) then if (Result.Enable=Enable) and (Result.Path=ExpPath) and (Result.Origin=Origin) then
exit; exit;
if Result.Enable then if Result.Enable then
@ -1585,9 +1591,9 @@ procedure TSimpleWebServerController.HookMacros;
end; end;
begin begin
IDEMacroSWSAddress:=Add('SWSAddress', 'Simple Web Server Address', @GetSWSAddress); IDEMacroSWSAddress:=Add('SWSAddress', rsSWSimpleWebServerAddress, @GetSWSAddress);
IDEMacroSWSPort:=Add('SWSPort', 'Simple Web Server Port', @GetSWSPort); IDEMacroSWSPort:=Add('SWSPort', rsSWSimpleWebServerPort, @GetSWSPort);
IDEMacroSWSExe:=Add('SWSExe', 'Simple Web Server Executable', @GetSWSExe); IDEMacroSWSExe:=Add('SWSExe', rsSWSimpleWebServerExecutable, @GetSWSExe);
end; end;
procedure TSimpleWebServerController.UnhookMacros; procedure TSimpleWebServerController.UnhookMacros;

View File

@ -11,6 +11,27 @@ resourcestring
rsSWSPort = 'Port'; rsSWSPort = 'Port';
rsSWSBindAny = 'Bind Any'; rsSWSBindAny = 'Bind Any';
rsSWSUserOrigin = 'User'; rsSWSUserOrigin = 'User';
rsSWError = 'Error';
rsSWErrorWriting = 'Error writing "%s"';
rsSWErrorCreatingDirectory = 'Error creating directory';
rsSWDirectoryNotFound = 'Directory not found';
rsSWSimpleWebServerAddress = 'Simple Web Server Address';
rsSWSimpleWebServerPort = 'Simple Web Server Port';
rsSWSimpleWebServerExecutable = 'Simple Web Server Executable';
rsSWWrongCompileserverExe = 'Wrong compileserver exe: %s';
rsSWServerExeIsNotExecutable = 'Server exe is not executable: "%s"';
rsSWFileNotFound = 'File not found: "%s"';
rsSWServerExecutableNotFoundInPATH = 'Server executable "%s" not found in '
+'PATH.';
rsSWServerDirectoryNotFound = 'Server directory "%s" not found.';
rsSWBindingOfSocketFailed = 'Binding of socket failed';
rsSWTheFollowingProcessAlreadyListens = 'The following process already '
+'listens:';
rsSWKillProcess = 'Kill process?';
rsSWKillPID = 'Kill PID %s';
rsSWTryAnotherPort = 'Try another port';
rsSWMissingServerExecutable = 'Missing server executable';
rsSWMissingLocalDirectory = 'Missing local directory';
implementation implementation