Reputation: 367
I have a Build (*.iss) file for INNO that gives the user the possibility of choosing between 4 languages when the setup.exe is executed. I would like the language chosen by the user to be saved in the Windows registry (or in a file where the setup.exe is located). This would be used as input to the installed program. The installed program will then dynamically change the language used for the menu items/messages to the language chosen by the user.
How can I this task be accomplished in the INNO *.iss file?
Upvotes: 2
Views: 1046
Reputation: 76713
You can store the value given by the {language}
constant. It returns the selected language identifier name (the name specified by the Name
parameter of the [Languages]
section entry). For instance, the following script will store either en
or nl
value (depending on which language the user selects) to the specified registry key:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
[Registry]
Root: HKLM; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; ValueName: "Language"; ValueData: "{language}"
In a code you can query the ActiveLanguage
function, which returns the same language identifier as the {language}
constant. To store this identifier into a text file in the form you've mentioned after the installation is done, you can use the following code:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "de"; MessagesFile: "compiler:Languages\German.isl"
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
S: string;
begin
if CurStep = ssPostInstall then
begin
S := Format('language = "%s"', [ActiveLanguage]);
SaveStringToFile('C:\File.txt', S, False);
end;
end;
Upvotes: 4