如何为卸载程序使用选定的语言?

How I can use selected language for uninstaller?

我的 .nsi 配置如下:

#########################################################################
## Language Selection Dialog Settings

## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software${APP_COMPANY}${APP_PRODUCT}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

## Languages (first language is the default language)
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Dutch"


## Language selection functions (for install and uninstall)
Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

## Uninstaller Functions
Function un.onInit
   !insertmacro MUI_UNGETLANGUAGE
FunctionEnd

但是当我尝试卸载时,卸载程序每次都会显示语言对话框。

我遵循 MUI2 自述文件,但我不知道自己做错了什么。

MUI_LANGDLL_REGISTRY_* 指定的注册表值由 MUI 自动保存在 MUI_PAGE_INSTFILES 页面上。如果您不使用此页面,那么您可以自己调用 MUI_LANGDLL_SAVELANGUAGE 宏或手动写入 $LANGUAGE.

的值

我建议只使用 MUI_PAGE_INSTFILES 页面,这样一切都会为您处理:

!define APP_COMPANY "Foo"
!define APP_PRODUCT "Bar"
!include MUI2.nsh
InstallDir "$Temp\Test"
RequestExecutionLevel user

#########################################################################
## Language Selection Dialog Settings

## Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT HKCU
!define MUI_LANGDLL_REGISTRY_KEY "Software${APP_COMPANY}${APP_PRODUCT}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES


## Languages (first language is the default language)
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Dutch"


## Language selection functions (for install and uninstall)
Function .onInit
  !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

## Uninstaller Functions
Function un.onInit
   !insertmacro MUI_UNGETLANGUAGE
FunctionEnd

Section
SetOutPath $InstDir
WriteUninstaller "$InstDir\Uninst.exe"
SectionEnd

Section Uninstall
DeleteRegKey HKCU "Software${APP_COMPANY}${APP_PRODUCT}"
DeleteRegKey /IfEmpty HKCU "Software${APP_COMPANY}"
Delete "$InstDir\Uninst.exe"
RMDir $InstDir
SectionEnd