How to Translate texts contained in MsgBox in Inno Setup? - installation

I have got a [code] section contained within my inno setup script which displays some information for the user during install. I would like to be able to translate these in the same language the user selected during install. They texts are currently in English and for example want to translate it in Russian, etc. I know I have to do something in the Language.isl file. Below is a example of such text.
if MsgBox('Previous program found. It is recommendeded to uninstall it and install a fresh program. Please note that your data will not be deleted during the uninstallation. Do you want to continue?', mbConfirmation, MB_YESNO) = IDYES then
begin etc

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
[CustomMessages]
CustomMessage=Undefined //just in case (should be equal to English)
english.CustomMessage=English Selected
german.CustomMessage=German Selected
polish.CustomMessage=Polish Selected
[Code]
function InitializeSetup: Boolean;
begin
Result := True;
MsgBox(ExpandConstant('{cm:CustomMessage}'), mbInformation, MB_OK);
end;

Related

Inno Setup to modify key values in app.config file while running setup.exe

I need to change the values of some keys in app.config file. I'm planning to use Inno Setup for this task.
I have found excellent tips of using XML parser and xpath selectors in this kind of tasks. However, I don't know what path to use to point to the key & value I want to change.
My app.config looks approximately like this:
<configuration>
<runtime>
</runtime>
<appSettings>
<add key="DefaultUrl" value="http://localhost/Some_application"/>
</appSettings>
</configuration>
So, I want to access the key "DefaultUrl" and change it's "value". How to point there?
$x("//configuration/appSettings[#key='DefaultUrl']")
doesn't seem to be correct since it returns nothing.
EDIT after Mirtheil's comment:
To change the key values I use this procedure:
procedure SaveAttributeValueToXML(const AFileName, APath, AAttribute,
AValue: string);
var
XMLNode: Variant;
XMLDocument: Variant;
begin
XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0');
try
XMLDocument.async := False;
XMLDocument.load(AFileName);
if (XMLDocument.parseError.errorCode <> 0) then
MsgBox('The XML file could not be parsed. ' +
XMLDocument.parseError.reason, mbError, MB_OK)
else
begin
XMLDocument.setProperty('SelectionLanguage', 'XPath');
XMLNode := XMLDocument.selectSingleNode(APath);
XMLNode.setAttribute(AAttribute, AValue);
XMLDocument.save(AFileName);
end;
except
MsgBox('An error occured!' + #13#10 + GetExceptionMessage,
mbError, MB_OK);
end;
end;
I call it
SaveAttributeValueToXML(Some_Application.exe.config', '//configuration/appSettings[#key=''DefaultUrl'']', 'value', 'https://Server_Name/Other_Application');
This call generates an exception on line
XMLNode.setAttribute(AAttribute, AValue);
Exception message: "Variant is null, cannot invoke"
EDIT 2:
I found the answer. Calling
SaveAttributeValueToXML(Some_Application.exe.config', '//configuration/appSettings/add[#key=''DefaultUrl'']', 'value', 'https://Server_Name/Other_Application');
changes the value of key "DefaultUrl".
I found the answer.
$x("//configuration/appSettings/add[#key='DefaultUrl']")
returns the node I want.

YAMLSyntaxError: Failed to resolve SEQ_ITEM node here at line X, column Y:

I'm getting this error when trying to run Netlify CMS
Error loading the CMS configuration
Config Errors:
YAMLSyntaxError: Failed to resolve SEQ_ITEM node here at line 10, column 1:
- name: Posts
^^^^^^^^^^^^^^…
Check your config.yml file.
I have checked the syntax and tried different syntax but I still get the same error for somewhere in the config.yml document.
This is the troubled config.yml document:
backend:
name: git-gateway
branch: master
media_folder: src/assets/images
media_library:
name: uploads
collections:
- name: Posts
label: Posts
create: true
folder: "/articles"
slug: articles/{{slug}}
fields:
- {label: Title, name: title, widget: string}
- {label: Publish Date, name: date, widget: datetime}
- {label: Featured Image, name: cover_image, widget: image}
- {label: Body, name: body, widget: markdown}
Here is a link to the files that I am getting the errors from https://drive.google.com/file/d/1OJPKJRgCljxAG5UuUxXkBPPNoUcyJe48/view?usp=sharing
The file you linked uses tabs for indentation. YAML uses spaces, see the spec:
In general, indentation is defined as a zero or more space characters at the start of a line.
To maintain portability, tab characters must not be used in indentation, since different systems treat tabs differently.
You need to convert the tabs to spaces.

Debugging non working Pascal Check condition (DirExists) in Inno Setup

I trying to compile a little setup program for future users, I have understood how change some stuff.
But now I would like to create a shortcut ONLY if the directory exist. I tried to do something like that but nothing happened ... :
[Icons]
; Start menu icon
Name: "{group}\Myprogram"; Filename: "{app}\Myprogram.exe"
; Desktop icon
Name: "{userdesktop}\Myprogram.exe"; Filename: "{app}\Myprogram.exe"; \
Check: DirExists(ExpandConstant('C:\[path]\test'))
Your code is ok. It should do what you want. To help with the debugging, implement a user function that logs the test like:
[Icons]
Name: "{userdesktop}\P680.exe"; Filename: "{app}\P680.exe"; \
Check: DirExistsLogged('C:\Users\administrator\Documents\Test')
[Code]
function DirExistsLogged(Path: string): Boolean;
begin
Result := DirExists(Path);
Log(Format('DirExists [%s] => %d', [Path, Result]));
end;
Log example, when the folder exists:
2019-12-31 15:04:59.565 DirExists [C:\Users\administrator\Documents\Test] => 1
2019-12-31 15:04:59.565 -- Icon entry --
2019-12-31 15:04:59.565 Dest filename: C:\Users\martin\Desktop\My Program.exe.lnk
2019-12-31 15:04:59.566 Creating the icon.
2019-12-31 15:04:59.583 Successfully created the icon.
2019-12-31 15:04:59.594 Saving uninstall information.
Log example, when the folder does not exist:
2019-12-31 15:06:23.960 DirExists [C:\Users\administrator\Documents\Test] => 0
2019-12-31 15:06:23.960 Saving uninstall information.

How to let user to browse to a file to be copied with Inno Setup

I need user to browse to a file, select it, and then have this file copied from selected source to app folder.
Following this post
How to show/use the user selected app path {app} in InputDirPage in Inno Setup?
and Inno Setup documentation, i came to this piece of code:
[Files]
Source: {code:GetDBPath}; DestDir: "{app}"; Flags: confirmoverwrite uninsneveruninstall;
[Code]
var
SelectDBPage: TInputDirWizardPage;
DBPath: String;
procedure InitializeWizard;
begin
SelectDBPage := CreateInputDirPage(wpSelectDir, 'Select file', 'Select file', 'Select file', False, '');
SelectDBPage.Add('');
SelectDBPage.Values[0] := ExpandConstant('{src}\DB.FDB');
DBPath := SelectDBPage.Values[0];
end;
function GetDBPath():String;
begin
Result := DBPath;
end;
My problem is to retrieve file path. At instruction 'Source: {code:GetDBPath}' i get an 'Unknown filename prefix {code:' error.
How can I refer to the selected file path in [File] section?
Thank you
You need to add the external flag to the [Files] entry. This means the source will be evaluated at run time and CAN include {code:...} constants.
You're also not getting the correct value in your GetDBPath() function. You're returning the value of DBPath that isn't updated after creating the page, instead of getting the latest value form the SelectDBPage.Values[0].

inno ide component selected by types

Inno ide for example,
have two types which specifies some components but I don't want to list all components same list,
user select first type then i want only list first type's files and if select second type then I want only list second type's files.
[Types]
Name: "sunucu"; Description: "Sunucu Bileşenleri";Flags: iscustom
Name: "istemci"; Description: "İstemci Bileşenleri"
[Components]
Name: "readme"; Description: "Envanter Tanımlama Aracı"; Types: istemci
Name: "readme\de1"; Description: "Yetkili Kullanıcı"; Flags: exclusive; Types: istemci
Name: "readme\de2"; Description: "Genel Kullanıcı"; Flags: exclusive; Types: istemci
Name: "Jhe"; Description: "Jenerik Harita Editörü"; Types: istemci
Name: "Mim"; Description: "Model İşletim Motoru"; Types: sunucu
Name: "OSSB"; Description: "Ortam Şartları Sunucu Birimi"; Types: sunucu
Name: "SIM_ART_PACKAGE"; Description: "Simülasyon Analiz ve Raporlama Aracı"; Types: istemci
Name: "SIM_PACKAGE"; Description: "Simülasyon Arayüz Modülü"; Types: istemci
Name: "SPM"; Description: "Simülasyon Planlama Modülü"; Types: istemci
Name: "VTKB"; Description: "Simülasyon Kayıt Modülü"; Types: sunucu
Name: "VSMS"; Description: "Simülasyon Koşturma Servisi"; Types: sunucu
Name: "VSMS\s1"; Description: "SKS KAYIT"; Types: sunucu
Name: "VSMS\s2"; Description: "SKS"; Types: sunucu
Name: "VSMS\s3"; Description: "SKS OYNATMA"; Types: sunucu
Inno can not hide/show components based on the type selected, and [Types] are not designed to completely change how the install works.
If the two types are completely different with no overlap, you're best off doing two separate installs, or have a custom page before hand asking which mode you want to install into and useing a check: function to determine whether to show them or not.

Resources