我正在使用nsis创建多个安装程序。我的安装程序包含EULA,自定义表单(即安装内容)。 我想有一个nsis脚本,并能够通过语言文件控制不同的元素的文本。 元素可以是:EULA文本,下一个按钮(即英语中的“next”和西班牙语中的“Proximo”)以及安装期间显示的任何其他文本。 实现这种多语种安装程序的正确方法是什么?
答案 0 :(得分:1)
如何使用多种语言的基本示例:
Name "Test"
RequestExecutionLevel user
Outfile "Test.exe"
#Generate some license files on the fly
!tempfile LicFile1
!appendfile "${LicFile1}" "Hello from license 1."
!tempfile LicFile2
!appendfile "${LicFile2}" "Hello from license 2!"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Danish.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Swedish.nlf"
LicenseLangString licenseData ${LANG_DANISH} "${LicFile1}"
LicenseLangString licenseData ${LANG_SWEDISH} "${LicFile2}"
LicenseData $(licenseData)
LangString ^CancelBtn ${LANG_DANISH} "!lecnaC" ; Override built-in string from .nlf just for fun
LangString myCustomString ${LANG_DANISH} "Foo"
LangString myCustomString ${LANG_SWEDISH} "Bar"
Page License
Page InstFiles
!include LogicLib.nsh
Function .onInit
Push ""
Push ${LANG_DANISH}
Push "Danish"
Push ${LANG_SWEDISH}
Push "Bork bork"
Push A ; LangDLL: A means auto count languages
LangDLL::LangDialog "Installer Language" "Please select the language of the installer"
Pop $LANGUAGE
${IfThen} $LANGUAGE == "cancel" ${|} Abort ${|}
FunctionEnd
Section "Dummy"
MessageBox MB_OK "$(myCustomString) and baz"
SectionEnd
!delfile "${LicFile1}"
!delfile "${LicFile2}"
另一个使用MUI和“外部”文件作为自定义字符串的示例:
Name "Test"
RequestExecutionLevel user
Outfile "Test.exe"
#Generate some language and license files for this example
!tempfile LicFile1
!appendfile "${LicFile1}" "Hello from license 1."
!tempfile LicFile2
!appendfile "${LicFile2}" "Hello from license 2!"
!tempfile CustomDanNsh
!appendfile "${CustomDanNsh}" '!insertmacro LANGFILE_EXT Danish$\n'
!appendfile "${CustomDanNsh}" '${LangFileString} myCustomString "red"$\n'
!tempfile CustomSweNsh
!appendfile "${CustomSweNsh}" '!insertmacro LANGFILE_EXT Swedish$\n'
!appendfile "${CustomSweNsh}" '${LangFileString} myCustomString "blue"$\n'
!include "MUI2.nsh"
!define MUI_LANGDLL_ALLLANGUAGES
!insertmacro MUI_PAGE_LICENSE "$(licenseData)"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro LANGFILE_INCLUDE "${CustomDanNsh}"
LicenseLangString licenseData 0 "${LicFile1}"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro LANGFILE_INCLUDE "${CustomSweNsh}"
LicenseLangString licenseData 0 "${LicFile2}"
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
Section "Dummy"
MessageBox MB_OK "White or yellow on $(myCustomString)"
SectionEnd
!delfile "${CustomDanNsh}"
!delfile "${CustomSweNsh}"
!delfile "${LicFile1}"
!delfile "${LicFile2}"
答案 1 :(得分:0)
NSIS对此有很大的支持。
此功能的示例名为MultiLanguage,它显示了如何将单独的语言加载到安装程序中并使用本地化的字符串。
您可以在 NSIS \ Examples \ Modern UI \ MultiLanguage.nsi
中找到它(我不确定我可以在这里粘贴整个脚本,这可能违反SO规则)