Archive: Where to define LangString variables


Where to define LangString variables
I want to show localized messages in the .OnInit section and use the following code :

......

!define MUI_BRANDINGTEXT " "
!insertmacro MUI_LANGUAGE "English"

!define MUI_BRANDINGTEXT " "
!insertmacro MUI_LANGUAGE "French"

LangString AC_AdminRights ${LANG_ENGLISH} "You must be logged in as an administrator when installing this program."
LangString AC_AdminRights ${LANG_FRENCH} "Vous devez ĂȘtre connectĂ© en tant qu'administrateur pour installer ce programme."

...

and the .onInit section looks like :

Function .onInit

;Language selection

!insertmacro MUI_LANGDLL_DISPLAY
LangDLL::LangDialog "Installer Language" "Please select a language."

Pop $LANGUAGE
StrCmp $LANGUAGE "cancel" 0 CheckAdmin
Abort

CheckAdmin:

ClearErrors
UserInfo::GetName
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +2
Goto IsAdmin

MessageBox MB_OK $(AC_AdminRights)
Abort

IsAdmin:

FunctionEnd

The problem is that the Message is always shown in English, even if I select the "French" installer language. Any help is welcome.

Thanks, Romain


Changes to $LANGUAGE in .onInit don't take affect right away but only after .onInit. Use it in .onGUIInit, or just show the message in .onGUIInit so it'll check in silent installers too.


Changes to $LANGUAGE in .onInit don't take affect right away but only after .onInit. Use it in .onGUIInit, or just show the message in .onGUIInit so it'll check in silent installers too.
Works fine, thanks ! :up: