Inno Setup - 根据系统语言设置默认组件

Inno Setup - Set Default Component depending on System Language

我对 InnoSetup 比较陌生,所以如果我遗漏了什么,请原谅。

情况: 我的程序被组织成 select 可用的组件。 "Core Component" 和 "Language Component" (以及其他一些在这里无关紧要)。 "Language Component" 包含 "English"、"Spanish" 等。该设置已本地化为组件支持的所有语言。

我想要实现的目标: 当用户使用例如西班牙语 OS 和 selects 西班牙语进行设置时,我希望 "Language Component > Spanish" 默认情况下自动 selected,但用户仍然可以 select 我的程序的其他语言,即使设置是西班牙语。

它现在做什么: 现在第一个语言元素是 select 默认情况下是 "English" 因为它是第一个元素。用户必须特别指定 select "Spanish" 或其他,无论安装使用何种语言。

问题:是否可以根据安装区域进行 Inno Setup select 或检查组件?

演示代码:

[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"

请注意: 使用这个似乎没有任何效果:

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

我无法使用此选项,因为用户在安装过程中无法 select 其他语言,如果他想更改我的应用程序语言,他唯一的选择就是更改整个设置语言。

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

结论: 我希望有一些方法可以使这项工作。我想知道为什么在 "Component" 上设置语言被忽略或没有效果但在编译时仍然没有显示任何错误。也许在 [代码] 部分可能会有这样的事情,但我对 Pascal 一无所知。

非常感谢任何帮助或为我指明正确的方向。 你好。

从这个页面 (http://www.jrsoftware.org/ishelp/index.php?topic=languagessection) 我读到了这个信息:

"If the ShowLanguageDialog [Setup] section directive is set to yes (the default), a Select Language dialog will be displayed which gives the user an opportunity to override the language Setup chose. On non Unicode Inno Setup languages that can't be displayed properly on the user's system will be hidden. See the [LangOptions] section help topic for details."

解决方案:大家好,感谢您的帮助。经过一些 google、大脑和大量失败的编译,我终于冷酷地破解了一些相当漂亮的解决方案。

以下是代码,以防有人觉得它有用:

[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"

我默认使用 "Installation Types" 检查语言。这个解决方案对我来说似乎工作得很好,并且可以不用市长 Pascal 编码。缺点是它需要每种语言的安装类型,如果包含多种语言,安装类型会变得相当大。我想知道是否有其他更优雅和紧凑的方式来做到这一点。

您好,感谢您的帮助!

更新:现在根本不涉及 pascal 脚本.. 更新 2:使用 ISPP 避免重复,使用元素的所有语言更容易使用和更好的可读性。