Inno设置i18n用于自定义面板

tom*_*nkt 7 installation inno-setup internationalization

我为Inno-Setup制作了一个自定义面板,我想要国际化.

我可以使用*.isl文件添加我的翻译密钥,还是必须使用[custommessages]?我如何访问[code]部分中的键.

不是使用i18n的创新示例.

汤姆

TLa*_*ama 9

1.我可以修改isl本地化文件吗?

如果你修改标准*.isl文件,或者创建你自己的修改过的文件,它就在你身上.请务必记住,如果您修改标准版本,它们可能会通过您安装的新版Inno Setup进行更新.这可能是许多人建议仅在该[CustomMessages]部分中创建条目的原因.

但是您当然可以创建一个单独的语言文件,您可以将其与每个Inno安装程序更新合并,或者更好,就像Miral建议的那样,在您自己的*.isl文件中指定自定义消息,然后在MessagesFile[Languages]部分的参数中指定该文件位于逗号分隔文件列表的末尾:

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl,compiler:YourEnMessages.isl"
Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl,compiler:YourNlMessages.isl"
Run Code Online (Sandbox Code Playgroud)

作为MessagesFile参数的参考状态:

指定多个文件时,将按指定顺序读取它们,因此最后一个消息文件将覆盖先前文件中的所有消息.

因此,如果您只创建仅包含section的*.isl文件[CustomMessages]并按照上述方式在脚本中指定它们,则不会破坏任何内容,您将获得单独的可重用语言文件.这样的自定义*.isl文件的结构可能看起来像以下[CustomMessages]部分:

[CustomMessages]
SomeCustomKey=Some custom value
...
Run Code Online (Sandbox Code Playgroud)

如果您要在许多设置中重复使用这些自定义消息,那么制作您自己的语言文件可能会更好.

2.如何从[代码]部分访问自定义消息?

通过使用CustomMessage功能.例如这样:

...

[CustomMessages]
; the following key value pair can be moved to the *.isl file into the same
; named file section, if needed; as a downside of doing that you'll need to
; keep track of changes if you update Inno Setup itself
SomeCustomKey=Some custom value

[Code]
procedure InitializeWizard;
var
  S: string;
begin
  S := CustomMessage('SomeCustomKey');
  MsgBox(S, mbInformation, MB_OK);
end;
Run Code Online (Sandbox Code Playgroud)