Archive: Multiple language support in .onInit?


Multiple language support in .onInit?
  Hi,

I'm working on an NSIS installer with multiple language support.
The multiple language support of NSIS works nicely in normal case.

However, when I try to add silent mode to the installer, multiple
language support no longer works as most logic (like command line
processing etc.) is now in .onInit(). That's expected as NSIS
manual mentioned that language was initialized after .onInit(). But
I really want to add multiple language support even for silent mode.
Is there any workaround? Is it possible to force language
initialization before the end of .onInit()?

Another possible solution is moving most initialization logic into
later stage, after .onInit(). However, that will make the script
hard to understand. Has anyone here did the same thing before?


This is not a bug - this sis a NSIS feature.
As it was mentioned several times (showthread.php?t=326317): languages are set AFTER .onInit function.

But there is simple workaround for this: $LANGUAGE variable is filled with selected language ID already in .onInit so it can be used to determine the language together with ${Switch}:

   ; Show language selection dialog

!insertmacro MUI_LANGDLL_DISPLAY

${Switch} $LANGUAGE
${Case} 1033
; English
StrCpy $R0 "${LoadingSession_LANG_ENGLISH}"
StrCpy $R1 "${PleaseWait_LANG_ENGLISH}"
${Break}
${Case} 1051
; Slovak
StrCpy $R0 "${LoadingSession_LANG_SLOVAK}"
StrCpy $R1 "${PleaseWait_LANG_SLOVAK}"
${Break}

${Default}
;English - default language if no match is found
StrCpy $R0 "${LoadingSession_LANG_ENGLISH}"
StrCpy $R1 "${PleaseWait_LANG_ENGLISH}"
${EndSwitch}

;$R0 and $R1 are filled with strings...
Banner::show /set 76 "$R0" "$R1"
As you can see there are no LangString(s) but simple defined symbols:

!define LoadingSession_LANG_ENGLISH            "Loading data..."

>!define PleaseWait_LANG_ENGLISH "Please wait..."
>!define LoadingSession_LANG_SLOVAK "Načítavam informácie..."
>!define PleaseWait_LANG_SLOVAK "Prosím čakajte..."