且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Inno Setup-如何在自定义页面中显示本地化的RTF文本

更新时间:2023-11-14 15:40:40

对于自定义页面的标题和描述,请定义自定义消息,与 Inno设置-如何本地化组件和类型名称?

For the caption and description of the custom page, define custom messages in the language files, the same way as in Inno Setup - How to localize component and type names?

[CustomMessages]
ISCustomPage1_Caption=Some caption
ISCustomPage1_Description=Some description

然后使用 CustomMessage函数函数使用这些自定义消息在您的代码中.

And then use these custom messages using the CustomMessage function function in your code.

对于RTF文本,***的解决方案是创建单独的.rtf文件并根据所选语言加载适当的文件.

For the RTF text, the best solution is to create separate .rtf files and load an appropriate one based on the selected language.

[Languages]
Name: "eng"; MessagesFile: "Idiomas\English.isl"
Name: "spa"; MessagesFile: "Idiomas\Spanish.isl"

[Files]
Source: "eng.rtf"; Flags: dontcopy
Source: "spa.rtf"; Flags: dontcopy

[Code]

var
  ISCustomPage1: TWizardPage;
  RichEditViewer1: TRichEditViewer;

procedure InitializeWizard;
var
  RtfName: string;
  Rtf: AnsiString;
begin
  { Creates custom wizard page }
  ISCustomPage1 :=
    CreateCustomPage(
      wpWelcome, CustomMessage('ISCustomPage1_Caption'),
      CustomMessage('ISCustomPage1_Description'));

  { RichEditViewer1 }
  RichEditViewer1 := TRichEditViewer.Create(WizardForm);
  with RichEditViewer1 do
  begin
    Parent := ISCustomPage1.Surface;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(417);
    Height := ScaleY(241);
    ReadOnly := True;
    ScrollBars := ssVertical;

    RtfName := ActiveLanguage + '.rtf';
    ExtractTemporaryFile(RtfName);
    if LoadStringFromFile(ExpandConstant('{tmp}\' + RtfName), Rtf) then
    begin
      UseRichEdit := True;
      RTFText  := Rtf;
    end;
  end;
end;