Skip to content
⌘ NSIS Forum Archive

LangString doesn't work in onInit event

5 posts

fabiochelly#

LangString doesn't work in onInit event

I got a problem : the message $(DESC_SpadNotFound) is always shown in french even when I choose english in the language combobox.

LangString DESC_SpadNotFound ${LANG_ENGLISH} "Spad 6 has not been found on this computer!"
LangString DESC_SpadNotFound ${LANG_FRENCH} "Spad version 6 n'a pas été trouvé sur votre système !"

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows\App Paths\winspad60.exe\Path\" ""
${If} ${Errors}
MessageBox MB_OK|MB_ICONINFORMATION "$(DESC_SpadNotFound)"
Abort
${Else}
StrCpy $INSTDIR "$0"
${EndIf}
FunctionEnd
kichik#
Search the forum for "oninit langstring" and find:

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.

Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
fabiochelly#
Thank you. The language problem is corrected.

But how can I abort the setup if I'm in a custom page and not in the .onInit function anymore?
kichik#
Using Quit.

Don't forget the custom page won't show in silent mode. You should add a check for that in .onInit.
fabiochelly#
Thank you very much. Finally, I replaced my LangString lines by tests. It's simpler as I only have one message string:
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows\App Paths\winspad60.exe\Path\" ""
${If} ${Errors}
${If} "$LANGUAGE" == "${LANG_FRENCH}"
MessageBox MB_OK|MB_ICONINFORMATION "Spad version 6 n'a pas été trouvé sur votre système !"
${Else}
MessageBox MB_OK|MB_ICONINFORMATION "Spad 6 has not been found on this computer!"
${EndIf}
Abort
${Else}
StrCpy $INSTDIR "$0"
${EndIf}
FunctionEnd