Archive: Odd LangString behavior


Odd LangString behavior
I'm reading in a language id from regsitry which doesn't match the ${LANGUAGE_*} values so I'm just switching the LANGID and popping the appropriate value into $LANGUAGE. The problem is that while the value of $LANGUAGE is correct it always prints the english error message. The license agreement is in the correct language; just never any of the error messages. All errors are thrown only in .onInit. Any ideas?


!define LANGID_ENGLISH 0
!define LANGIS_FRENCH 1

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"

LicenseLangString myLicenseData ${LANG_ENGLISH} "local\license.txt.EN"
LicenseLangString myLicenseData ${LANG_FRENCH} "local\license.txt.FR"
LicenseData $(myLicenseData)

LangString emsg_InstallerAlreadyRunning ${LANG_ENGLISH} "English - Installer already running."
LangString emsg_InstallerAlreadyRunning ${LANG_FRENCH} "French - Installer already running."

Function .onInit

; Get the game language value
ReadRegDWORD $LANGID HKLM "..." "Language"
${Select} $LANGID
${Case} ${LANGID_FRENCH}
Push ${LANG_FRENCH}
Pop $LANGUAGE
${Default}
Push ${LANG_ENGLISH}
Pop $LANGUAGE
${EndSelect}

MessageBox MB_OK|MB_ICONEXCLAMATION "$LANGUAGE"

; Prevent multiple instances of installer
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "TSLRP") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "$(emsg_InstallerAlreadyRunning)"
Abort
...

Possible solutions:

Solution 1:

Typo:

LANGIS_FRENCH
should be
LANGID_FRENCH
Solution 2:
Language IDs are wrong. English is 1033 and French is 1036.

Solution 3:
Try:
ReadRegDWORD $LANGID HKLM "..." "Language" ; edit this!
${Select} $LANGID
${Case} ${LANGID_FRENCH}
StrCpy $LANGUAGE 1036
${Default}
StrCpy $LANGUAGE 1033
${EndSelect}

Edit: Modern UI will require the language ID to be correct (i. e. 1033 for english and 1036 for french) or you won't see much of a ui.

-dandaman32

1) Typo isn't in my original; I didn't copy paste...foolish me :igor:

2) The MessageBox displays the proper value of $LANGUAGE for both the first and second instance of the installer.

3) And I do in fact get the UI to come up. It's just that I'm trying to display the "The installer is already running" in the language of the user. But despite the fact that the value in $LANGUAGE (1036) is correct for both instances I always get the English error message.


That's because $LANGUAGE variable is set in .onInit, but NSIS re-reads it only after .onInit. So your multilanguage variable "emsg_InstallerAlreadyRunning" will be "multilanguage" only after .onInit execution.
Here and here discussion. Or search the forum for "oninit", "multilanguage", "messagebox".


Appreciate it!