【问题标题】:Use Built-in Messages in Inno Setup在 Inno Setup 中使用内置消息
【发布时间】:2013-12-19 18:40:48
【问题描述】:

如何在 Inno Setup 中使用内置消息?

在“Default.isl”中有一条消息“FullInstallation”,我想在我的 Inno Setup 脚本中使用它。因此,此消息已翻译成 Inno Setup 支持的所有语言。这样我就不用自己翻译这篇文章了。

我看到“Default.isl”有一个[CustomMessages] 部分,我可以使用(例如){cm:CreateDesktopIcon}(因为“CreateDesktopIcon”作为自定义消息存在)。

如何使用[CustomMessages] 部分未列出的其他消息之一?

【问题讨论】:

    标签: internationalization inno-setup


    【解决方案1】:

    据我所知,没有类似 {cm:...} 的常量可以用来扩展 [Messages] 条目。如果我是对的,那么这取决于你想在哪里使用这样的常量。如果它在脚本部分,那么您需要使用带有调用 SetupMessage 函数的 getter 的 scripted constant,通过它您可以通过 this file 中列出的常量来扩展所选语言的这些内置消息。

    如您所见,每个消息常量都只有语言文件中 [Messages] 条目的 msg 前缀。

    例如,要将WizardPreparing 消息扩展为[Run] 部分条目的Description 值,您可以这样扩展msgWizardPreparing 常量:

    [Run]
    Filename: "MyProg.exe"; Description: "{code:GetDescription}"
    
    [Code]
    function GetDescription(Value: string): string;
    begin
      Result := SetupMessage(msgWizardPreparing);
    end;
    

    [Code] 部分的情况自然更容易,因为您可以直接在那里使用SetupMessage 函数。因此,例如,要显示带有扩展的 CannotContinue 消息的消息框,您只需这样扩展 msgCannotContinue 常量:

    [Code]
    procedure InitializeWizard;
    var
      S: string;
    begin
      S := SetupMessage(msgCannotContinue);
      MsgBox(S, mbInformation, MB_OK);
    end;
    

    【讨论】:

    • 我正在尝试在脚本部分使用它,但如果没有直接的方法,这是一个很好的解决方案。
    • 脚本部分只有这个函数。我想说这不会有任何常数,因为这些消息的目的主要是供内部使用。
    猜你喜欢
    • 2016-06-23
    • 2012-03-05
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    相关资源
    最近更新 更多