Help with multi-language support
Hello,
I am just trying to work some multi-language support into my installer and have come with a couple of issues. I have created a simple script to demonstrate my problems (derived from one of the multi-language examples):
;NSIS Modern User Interface
;Multilingual Example Script
;Written by Joost Verburg
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
Var name
;Name and file
Name $name
OutFile "MultiLanguage.exe"
;Default installation folder
InstallDir "$LOCALAPPDATA\Modern UI Test"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\Modern UI Test" ""
;Request application privileges for Windows Vista
RequestExecutionLevel user
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
!define MUI_WELCOMEPAGE_TITLE "$(WELCOME_TEXT)"
!define MUI_DIRECTORYPAGE_TEXT_TOP "$(DIRECTORY_BROWSER_TEXT)"
;--------------------------------
;Language Selection Dialog Settings
;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\Modern UI Test"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
; Load our languages
!include "langmacros.nsh"
!insertmacro LANG_LOAD "English"
!insertmacro LANG_LOAD "French"
!insertmacro LANG_LOAD "Italian"
!insertmacro LANG_LOAD "German"
!insertmacro LANG_LOAD "Spanish"
!insertmacro LANG_LOAD "PortugueseBR"
;--------------------------------
;Reserve Files
;If you are using solid compression, files that are required before
;the actual installation should be stored first in the data block,
;because this will make your installer start faster.
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
SetOutPath "$INSTDIR"
;ADD YOUR OWN FILES HERE...
;Store installation folder
WriteRegStr HKCU "Software\Modern UI Test" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
;--------------------------------
;Installer Functions
Function .onInit
!define MUI_LANGDLL_WINDOWTITLE "$(LANGDIAG_TITLE)"
!define MUI_LANGDLL_INFO "$(LANGDIAG_TEXT)"
!define MUI_LANGDLL_ALWAYSSHOW
!insertmacro MUI_LANGDLL_DISPLAY
WriteRegStr "${MUI_LANGDLL_REGISTRY_ROOT}" "${MUI_LANGDLL_REGISTRY_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" $LANGUAGE
StrCpy $name "$(APP_NAME)"
MessageBox MB_OK "$(LANGIS_TEXT) $LANGUAGE"
FunctionEnd
;--------------------------------
;Descriptions
;USE A LANGUAGE STRING IF YOU WANT YOUR DESCRIPTIONS TO BE LANGAUGE SPECIFIC
;Assign descriptions to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} "$(TEST_SECTION)"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;ADD YOUR OWN FILES HERE...
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
SectionEnd
;--------------------------------
;Uninstaller Functions
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
and sample english.nsh:
!define LANG "ENGLISH" ; Must be the lang name define my NSIS
!insertmacro LANG_STRING APP_NAME "[EN] Modern UI Setup"
!insertmacro LANG_STRING TEST_SECTION "[EN] A Test Section"
!insertmacro LANG_STRING WELCOME_TEXT "[EN] Welcome to installer"
!insertmacro LANG_STRING DIRECTORY_BROWSER_TEXT "[EN] Click Next to install to this folder, or click Browse to install to a different folder."
!insertmacro LANG_STRING LANGDIAG_TITLE "[EN] Installer language"
!insertmacro LANG_STRING LANGDIAG_TEXT "[EN] Please select the language"
!insertmacro LANG_STRING LANGIS_TEXT "[EN] Language is:"
all other language headers are the same except have [FR], [ES], etc...
The problem I am having is that the two lines:
StrCpy $name "$(APP_NAME)"
MessageBox MB_OK "$(LANGIS_TEXT) $LANGUAGE"
Do not respect the language choice. It's always displaying the english language.
What am I doing wrong?
Thanks