How can I use language files with custom messages with preprocessor constants?

六眼飞鱼酱① 提交于 2020-11-28 02:42:00

问题


I want to have all CustomMessages in language files (extension isl). Also, some of the messages contain preprocessor constants, e.g.

ALREADY_INSTALLED={#MyAppName} is already installed on this computer.

The message should be displayed like this:

"My-really-nice-App is already installed on this computer"

But what I get is:

"{#MyAppName} is already installed on this computer."

The following works like a charm when I have the code, the message defined in a [CustomMessages]-topic and #define MyAppName in the same iss file:

MsgBox(ExpandConstant('{cm:ALREADY_INSTALLED}'), ...);

Any clues?


回答1:


Only .iss file is preprocessed, not .isl files.

But you can use FmtMessage function:

FmtMessage(CustomMessage('ALREADY_INSTALLED'), ['{#MyAppName}'])

With

ALREADY_INSTALLED=%1 is already installed on this computer.

Note that in Pascal Script code, you better use CustomMessage('FOO'), instead of ExpandConstant('{cm:FOO}').


Similar question: Pass parameters to custom messages defined in .isl files.

If you need to preprocess the standard messages, see Can I use .isl files for the messages with preprocessor directives in Inno Setup?



来源:https://stackoverflow.com/questions/52700413/how-can-i-use-language-files-with-custom-messages-with-preprocessor-constants

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!