Creating command-line parameters shortcut depending of language selected in Inno Setup

Viewed 178

I am trying to use a conditional in command-line parameters - I have used this tutorial and it works great: Creating a shortcut to execute a program with command-line parameters in Inno Setup

I am creating an installer, I would like to know how to do if the user selects the Spanish language, the created shortcut has the parameter: -spanish

#define MyAppName "The software"
#define MyAppVersion "1.0"
#define MyAppPublisher "Inc."

[Languages]
Name: "english"; MessagesFile: "compiler:Languages\English.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"

[Files]
Source: "C:\Program Files (x86)\The software\*"; DestDir: "{app}"; \
    Flags: ignoreversion recursesubdirs createallsubdirs

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Soft name"; Filename: "{app}\soft.exe"; \
    Parameters: "-english"; IconFilename: {app}\icon.ico;
1 Answers

Either use the Languages parameter:

[Icons]
Name: "{commondesktop}\Soft name"; Filename: "{app}\soft.exe"; \
    Parameters: "-english"; IconFilename: {app}\icon.ico; Languages: english
Name: "{commondesktop}\Soft name"; Filename: "{app}\soft.exe"; \
    Parameters: "-russian"; IconFilename: {app}\icon.ico; Languages: russian
...

Or use a scripted constant and the ActiveLanguage function. If your language Name and the switch name always matches, it is very easy:

[Icons]
Name: "{commondesktop}\Soft name"; Filename: "{app}\soft.exe"; \
    Parameters: "-{code:ActiveLanguage}"; IconFilename: {app}\icon.ico

If they do not match, you will have to implement a proxy function that translates the ActiveLanguage value to an equivalent switch name.

Related