如何使用 NSIS 根据语言或区域设置在许可协议屏幕中显示最终用户许可协议 ("EULA")

How to show the End-User License Agreement ("EULA") in the license agreement screen based on the language or locale using NSIS

如何根据语言或区域设置在许可协议屏幕中显示最终用户许可协议 ("EULA")。

下面是在许可协议屏幕中显示许可协议的代码行。但它只显示英文。

!insertmacro MUI_PAGE_LICENSE "C:\Program Files (x86)\NSIS\Docs\Modern UI\license.rtf"

我将所有其他语言 license.rtf 文件放在一个公共文件夹中。然后当我试图写

${If} $Language == 1033
  !insertmacro MUI_PAGE_LICENSE "C:\Program Files (x86)\NSIS\Docs\Modern UI\license.rtf"
  ${EndIf}

显示编译错误"Error: command StrCmp not valid outside Section or Function"

MUI 文档告诉您该怎么做:

For a license text in multiple languages, LicenseLangString can be used. Refer the NSIS Users Manual for more information about installers with multiple languages.

NSIS 用户手册说:

LicenseLangString license ${LANG_ENGLISH} license-english.txt

LicenseLangString license ${LANG_FRENCH} license-french.txt

LicenseLangString license ${LANG_GERMAN} license-german.txt

LicenseData $(license)

对于 MUI,您只需将 MUI 许可页面指向您的 LicenseLangString:

!include MUI2.nsh
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(translatedlicensefile)
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE English
LicenseLangString translatedlicensefile ${LANG_ENGLISH} "lic-eng.txt"
!insertmacro MUI_LANGUAGE Swedish
LicenseLangString translatedlicensefile ${LANG_SWEDISH} "lic-swe.txt"