Multilanguage MessageBox $(STRING) in function .onInit and un.onInit
Multilanguage MessageBox $(STRING) in function .onInit and un.onInit
I enjoy NSIS and it is really great!!! ;-)
I use ModernUI, InstallOptions and and Multilanguages
In my installs I need to interact with user when install or uninstall inits, but
LangString doesnt work for me in this cases. I use latest snapshot vrom sourceForge(15 October), OS Xp and Win98, for example:
Code:----------------------------------------
LoadLanguageFile "${DISTF}\Contrib\Language files\English.nlf"
!include "${DISTF}\Contrib\Modern UI\Language files\English.nsh"
LoadLanguageFile "${DISTF}\Contrib\Language files\Dutch.nlf"
!include "${DISTF}\Contrib\Modern UI\Language files\Dutch.nsh"
LangString INSTALL_CHEKC_EXIST_INSTALLATION ${LANG_ENGLISH} "Installer will check for existing ${PROGNAME}
instalation.$\nContinue with check?"
LangString INSTALL_CHEKC_EXIST_INSTALLATION ${LANG_DUTCH} "NIDERL: Installer will check for existing ${PROGNAME}
instalation.$\nContinue with check?"
LangString un.UN_MSG_TEST1 ${LANG_ENGLISH} "Test MSG mixed with variable ${PROGNAME}"
LangString un.UN_MSG_TEST1 ${LANG_DUTCH} "NIDERL: Test MSG mixed with variable ${PROGNAME}"
LangString un.UN_MSG_TEST2 ${LANG_ENGLISH} "Test MSG no variable"
LangString un.UN_MSG_TEST2 ${LANG_DUTCH} "NIDERL: Test MSG no variable"
Function .onInit
Push Tahoma
Push 8
Push ${LANG_ENGLISH}
Push ${MUI_ENGLISH_LANGNAME}
Push ${LANG_DUTCH}
Push ${MUI_DUTCH_LANGNAME}
Push 2F ; 8 is the number of languages, F = change font
LangDLL::LangDialog "Installer Language" "Please select a language."
Pop $LANGUAGE
StrCmp $LANGUAGE "cancel" 0 +2
Abort
...
MessageBox MB_YESNO|MB_ICONQUESTION|MB_TOPMOST|MB_DEFBUTTON1 "$(INSTALL_CHEKC_EXIST_INSTALLATION)" IDYES NoAbort
...
Function
Function un.onInit
...
Push ${MUI_TEMP1}
;Get the language from the registry (save by uninstaller)
ReadRegStr ${MUI_TEMP1} HKCU "Software\MyCompany\${PROGNAME}" "Installer Language"
StrCmp ${MUI_TEMP1} "" +2
StrCpy $LANGUAGE ${MUI_TEMP1}
Pop ${MUI_TEMP1}
...
MessageBox MB_YESNO|MB_ICONQUESTION|MB_TOPMOST|MB_DEFBUTTON1 "$(UN_MSG_TEST1)" IDYES NoAbort
MessageBox MB_YESNO|MB_ICONQUESTION|MB_TOPMOST|MB_DEFBUTTON1 "$(UN_MSG_TEST2)" IDYES NoAbort
...
Function
Code:END ----------------------------------------
Multilaguage MessageBox $(MSG) works fine in Sections and other cases, but in ".onInit" and "un.onInit"
it does not recognise diferent languages and variable "$(INSTALL_CHEKC_EXIST_INSTALLATION)" init with first value in
".onInit" and "$(un.UN_MSG_TEST1)" with last value in "un.onInit", doesn't matter of language chosen.
Am i doing something wrong ..? What is the general solution for multilanguage MessageBoxes in Multilang installs..?
I have my solution for onInit functions, same as "MUI_ABORTWARNING" before, see attachment, but i think LangString idea is better.:up: