简体   繁体   English

如何向 NSIS 安装程序添加新页面

[英]How to add a new page to the NSIS installer

My requirement is, I need to add a new page (for eg., "newpage") after the "Directory" page.我的要求是,我需要在“目录”页面之后添加一个新页面(例如,“newpage”)。 For this first i need to change the pushbutton (Install) to (Next) in the Directory page so that I can create a new page by clicking on "Next".首先,我需要将目录页面中的按钮(安装)更改为(下一步),以便我可以通过单击“下一步”来创建一个新页面。

For this I verified the "Directory" page in the path (NSIS/Contrib/Modern UI 2/Pages)为此,我验证了路径中的“目录”页面(NSIS/Contrib/Modern UI 2/Pages)

I didn't find "我没有找到“

Later i verified the "Interface" page and found "Next", "Cancel", and "Back" buttons.后来我验证了“界面”页面,找到了“下一步”、“取消”和“返回”按钮。 But didn't find the "Install" button.但是没有找到“安装”按钮。

Where can i find the "Install" button?我在哪里可以找到“安装”按钮?

And also how to create a new page?以及如何创建一个新页面? Can we create a new NSI file for the "newpage" and include it in the main .nsi file?我们可以为“newpage”创建一个新的 NSI 文件并将其包含在主 .nsi 文件中吗?

If i create a new NSI file, do i need to create strings for all the required languages in different files for localization?如果我创建一个新的 NSI 文件,我是否需要在不同的文件中为所有必需的语言创建字符串以进行本地化?

And also If i create different language files, can i place those in the local directory folder?而且如果我创建不同的语言文件,我可以将它们放在本地目录文件夹中吗?

NSIS automatically changes the Next/Install button text for you. NSIS 会自动为您更改下一步/安装按钮文本。 Only the page before the InstFiles page uses the "Install" string as the button text.只有 InstFiles 页面之前的页面使用“安装”字符串作为按钮文本。

You must use a plug-in to create a custom page.您必须使用插件来创建自定义页面。 The most commonly used page plug-in is nsDialogs and it's part of the default NSIS install.最常用的页面插件是nsDialogs ,它是默认 NSIS 安装的一部分。

You don't have to put the custom page nor the translation strings in separate .nsh files, you can put the code directly in your .nsi:您不必将自定义页面或翻译字符串放在单独的 .nsh 文件中,您可以将代码直接放在 .nsi 中:

Unicode True
Page Components
Page Directory
Page Custom MyPageCreate
Page InstFiles

LoadLanguageFile "${NSISDIR}\Contrib\Language Files\English.nlf"
LangString MyLabelText ${LANG_ENGLISH} "Hello World"
LoadLanguageFile "${NSISDIR}\Contrib\Language Files\Swedish.nlf"
LangString MyLabelText ${LANG_SWEDISH} "Hej bork bork"

!include nsDialogs.nsh

Function MyPageCreate
nsDialogs::Create 1018
Pop $0

${NSD_CreateLabel} 0 0 100% 12u "$(MyLabelText)"
Pop $0

nsDialogs::Show
FunctionEnd

If you want to put translations in separate files then you should take a look at \\NSIS\\Include\\LangFile.nsh , it contains a example that uses MUI and helper macros to create additional translation strings in external files.如果您想将翻译放在单独的文件中,那么您应该查看\\NSIS\\Include\\LangFile.nsh ,它包含一个使用 MUI 和帮助程序宏在外部文件中创建附加翻译字符串的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM