Jorge B.
Jorge B.

Reputation: 1213

How I can use selected language for uninstaller?

I have my .nsi with this configuration:

#########################################################################
## 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

But when I try to uninstall the uninstaller shows me the language dialog everytime.

I follow the MUI2 README and I don't know what I'm doing wrong.

Upvotes: 0

Views: 1271

Answers (1)

Anders
Anders

Reputation: 101764

The registry value specified by MUI_LANGDLL_REGISTRY_* is saved automatically by MUI on the MUI_PAGE_INSTFILES page. If you are not using this page then you can call the MUI_LANGDLL_SAVELANGUAGE macro yourself or manually write the value of $LANGUAGE.

I would recommend just using the MUI_PAGE_INSTFILES page so everything is taken care of for you:

!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

Upvotes: 3

Related Questions