Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup - Set Default Component depending on System Language

I'm relatively new to InnoSetup so excuse me if I'm missing something.

Situation: My program is organized into selectable components. "Core Component" and "Language Component" (and some other which are irrelevant here). The "Language Component" contains "English", "Spanish", and some more.. The setup is localized in all languages that the components support.

What I'm trying to achieve: When the user has for example a Spanish OS and selects the Spanish language for the setup, I want the "Language Component > Spanish" to be selected automatically BY DEFAULT, but the user still be able to select an other language for my programm even if the setup is in Spanish.

What it does right now: Right now the first language element is selected by default which is "English" as it is the first element. The user has to specifically select "Spanish" or other no matter what language is being used for the setup.

Question: Is it possible to make Inno Setup select or check components depending on the setup locale?

Demo Code:

[Setup]
AppName=My App
AppVersion=1.0
DefaultDirName={pf}\My App

[Components]
Name: "core_files"; Description: "Core Component"; Types: full compact custom; Flags: fixed
Name: "lang_files"; Description: "Language Component"; Types: full compact custom; Flags: fixed
Name: "lang_files\en"; Description: "English"; Flags: exclusive
Name: "lang_files\es"; Description: "Spanish"; Flags: exclusive;

[Files]
;Source: "Files\*"; DestDir: "{app}"; Components: game_files
;Source: "Files_EN\*"; DestDir: "{app}"; Components: lang_files\en
;Source: "Files_ES\*"; DestDir: "{app}"; Components: lang_files\es

[Icons]  
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl"

Please note: Using this does not seems to have any effect:

Name: "lang_files\es"; Description: "Spanish"; Languages: es; Flags: exclusive;

Using this is not an option for me, as the user cannot select an other language during installation, the only option for him would be changing the whole setup language if he wants to change my app language.

Source: "Files_ES\*"; DestDir: "{app}"; Languages: es; Components: lang_files\es

Conclusion: I hope there is some way to make this work. I was wondering why setting the language on the "Component" is being ignored or has just no effect but still does not show any errors while compiling. Maybe something like this would be possible in the [Code] section but I don't know anything about Pascal.

Any help or pointing me in the right direction is highly apreciated. Greetings.

like image 748
Robert Koszewski Avatar asked Sep 10 '26 03:09

Robert Koszewski


1 Answers

SOLUTION: Hello everybody, thanks for the help. With a bit of google, brain and a lot of failed compiles I finally cold hack up some reasonably good looking solution.

Here is the code in case somebody would find it useful:

[Setup]
AppName=My App
AppVersion=1.0
DefaultDirName={pf}\My App

[Types]
Name: "full_en"; Description: "Full installation"; Languages: en; 
Name: "full_es"; Description: "Full installation"; Languages: es;
Name: "custom"; Description: "Custom installation"; Flags: iscustom
; Full installation (With all languages)
#define full "full_en full_es"

[Components]
Name: "core_files"; Description: "Core Component"; Types: {#full} custom; Flags: fixed
Name: "lang_files"; Description: "Language Component"; Types: {#full} custom; Flags: fixed
Name: "lang_files\en"; Description: "English"; Types: full_en custom; Flags: exclusive
Name: "lang_files\es"; Description: "Spanish"; Types: full_es custom; Flags: exclusive;

[Files]
;Source: "Files\*"; DestDir: "{app}"; Components: game_files
;Source: "Files_EN\*"; DestDir: "{app}"; Components: lang_files\en
;Source: "Files_ES\*"; DestDir: "{app}"; Components: lang_files\es

[Icons]  
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl"

I'm using "Installation Types" to check the languages by default. This solution seems to work quite well for me right and works whichout mayor Pascal coding. As drawback is that it Requires per-language installation types, which can get quite big if you include many languages. I wonder if there is some other more elegand and compact way to do that.

Greetings and thanks for the help!

UPDATED: No pascal scripting involved at all now.. UPDATED 2: Using ISPP to avoid duplication, easier use and better readability using all languages for an element.

like image 168
Robert Koszewski Avatar answered Sep 13 '26 03:09

Robert Koszewski