[CustomMessages] section

[CustomMessages] section用来定义自定义的一些{cm:}常量.

一个定义和使用的例子。

[CustomMessages]
CreateDesktopIcon=Create a &desktop icon

[Tasks]
Name: desktopicon; Description: "{cm:CreateDesktopIcon}"

CustomMessages是支持带参数的,从1%到9% 。支持重排列参数(例如,2%移动到了1%前面),也支持重复的参数(例如,1% …1% 2% )。在有参数的message中, 用两个连续的“%”来嵌入一个“%”,“%n”会创建一个line break。

In cases where there are multiple [Languages] section entries, specifying a [CustomMessages] section entry in your script (as opposed to an .isl file) will by default override that message for all languages. To apply a [CustomMessages] section entry to only one language, prefix it with the language’s internal name followed by a period. For example:

nl.CreateDesktopIcon=Maak een snelkoppeling op het &bureaublad

Currently, the .isl files for all languages that come with Inno Setup have the following custom messages defined and translated for each language (shown here with their English values):

NameAndVersion=%1 version %2
AdditionalIcons=Additional icons:
CreateDesktopIcon=Create a &desktop icon
CreateQuickLaunchIcon=Create a &Quick Launch icon
ProgramOnTheWeb=%1 on the Web
UninstallProgram=Uninstall %1
LaunchProgram=Launch %1
AssocFileExtension=&Associate %1 with the %2 file extension
AssocingFileExtension=Associating %1 with the %2 file extension...
AutoStartProgramGroupDescription=Startup:
AutoStartProgram=Automatically start %1
AddonHostProgramNotFound=%1 could not be located in the folder you selected.%n%nDo you want to continue anyway?

You may use these predefined custom messages in your own script. An example which uses UninstallProgram:

[Icons]
Name: "{group}\{cm:UninstallProgram,My Program}"; Filename: "{uninstallexe}"

1 {cm:MessageName}

{cm:MessageName}
{cm:MessageName,Arguments}
Embeds a custom message value based on the active language.

  • MessageName specifies the name of custom message to read from. See the [CustomMessages] section documentation for more information.
  • Arguments optionally specifies a comma separated list of arguments to the message value.
  • If you wish to include a comma, vertical bar (“|”), or closing brace (“}”) inside the constant, you must escape it via “%-encoding.” Replace the character with a “%” character, followed by its two-digit hex code. A comma is “%2c”, a vertical bar is “%7c”, and a closing brace is “%7d”. If you want to include an actual “%” character, use “%25”.
  • Each argument in Arguments may include constants. Note that you do not need to escape the closing brace of a constant as described above; that is only necessary when the closing brace is used elsewhere.
Example:
{cm:LaunchProgram,Inno Setup}

2 使用案例

[Run]
;运行的程序信息
Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
; ViewHelpManual在语言文件中定义
Filename: "{app}\{#AppUserGuide}"; Description: "{cm:ViewHelpManual}"; Flags: postinstall shellexec skipifsilent  unchecked

效果:
[CustomMessages] section_第1张图片

参考资料

[1] https://jrsoftware.org/ishelp/index.php?topic=custommessagessection
[2] https://jrsoftware.org/ishelp/index.php?topic=consts

你可能感兴趣的:(InnoSetup,InnoSetup)