Archive: Nsis Mui_langdll_display


Nsis Mui_langdll_display
Hello. I'm new to NSIS and i need to display language selection dialog with hardcoded default language. It is not english.

As i understand MUI_LANGDLL_DISPLAY does not provide such a possibility. Is there any way to implement my own language selection dialog avoiding C/C++ DLL creation? Could u give me a simple example or a link to the right place to read about this?


Why not create your own language file?

Stu


Ok lets assume you add a custom language to the dialog (which you can) you will get your custom language id pushed onto the stack afterwards. You would then need to do something with this language id (i.e. ${If} $LANGUAGE == 12345) but there's nothing you can do if the language is hard coded?

Stu


Afrow,

u missunderstand me. I have a translation. I need my language be first in the list. Here is an example:

...
; langs
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "English"
...
Function .onInit

; language selection dialog
!insertmacro MUI_LANGDLL_DISPLAY
...
FunctionEnd


MUI_LANGDLL_DISPLAY shows a dialog and sometimes "Russian" is selected by default, sometimes English. As i understand, it depend on different system settings (Regional and lang options etc). But i need "Russian" to be the 1st in the combo ALWAYS.

I've made a workaround using Page custom. Here it is:
...
; installer pages
Page custom LangSelector
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
...
Function LangSelector

nsDialogs::Create 1018
Pop $Dialog

${If} $Dialog == error
Abort
${EndIf}

${NSD_CreateGroupBox} 0 0 100% 125 "Выберите язык установки"
Pop $GroupBox

; RU line
${NSD_CreateBitmap} 25 31 16 11 ""
Pop $FlagRU
${NSD_SetImage} $FlagRU "ru.bmp" $hFlagRU
${NSD_CreateRadioButton} 60 25 50% 25 "Ð_усский"
Pop $LangRU
${NSD_OnClick} $LangRU LangChanged
${NSD_Check} $LangRU ; !!! this is always default !!!

; GB line
${NSD_CreateBitmap} 25 81 16 11 ""
Pop $FlagGB
${NSD_OnClick} $FlagGB LangChanged
${NSD_SetImage} $FlagGB "gb.bmp" $hFlagGB
${NSD_CreateRadioButton} 60 75 50% 25 "English"
Pop $LangGB
${NSD_OnClick} $LangGB LangChanged

nsDialogs::Show

; free resources
${NSD_FreeImage} $FlagRU
${NSD_FreeImage} $FlagGB

FunctionEnd
...

And now I have another problem: how should i setup selected language so the other pages use correct language? Here is what i did:
...
Function LangChanged
Pop $0 ; radio box handle that was clicked
${If} $0 == $LangRU
Push ${LANG_RUSSIAN}
Pop $LANGUAGE
${NSD_SetText} $GroupBox "Выберите язык установки"
${EndIf}
${If} $0 == $LangGB
Push ${LANG_ENGLISH}
Pop $LANGUAGE
${NSD_SetText} $GroupBox "Select installer language"
${EndIf}
FunctionEnd


It is incorrect and does not change language... How to change it except using $LANGUAGE (as i did)?

Are you using the MUI_LANGDLL_REGISTRY_* defines?
$LANGUAGE has to be set in .onInit before any dialogs are shown.

Stu


Originally posted by Afrow UK
Are you using the MUI_LANGDLL_REGISTRY_* defines?
No, i don't use MUI_LANGDLL_REGISTRY_* defines.

Originally posted by Afrow UK
$LANGUAGE has to be set in .onInit before any dialogs are shown.

Stu
Thank you... So, custom page is not a right way for me. Below is a short example demonstrating my problem, if u compile it and run you will see "English" is a default. I need change it to "Russian". Any proposals?


; includes
!include "MUI2.nsh"

; configure
Name "Example"
OutFile "Example.exe"

; installer pages
!insertmacro MUI_PAGE_INSTFILES

; langs
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "English"

; localized messages
LangString HELLO_WORLD ${LANG_RUSSIAN} "Привет, мир!"
LangString HELLO_WORLD ${LANG_ENGLISH} "Hello, world!"

Function .onInit
; ask for installer language
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Section "First and the only"
DetailPrint $(HELLO_WORLD)
SectionEnd

You can set the default language in the registry.

Check the MUI documentation (Settings for registry storage of selected language).
If you want your users to be able to select another language, define MUI_LANGDLL_ALWAYSSHOW as well.


Originally posted by jpderuiter
You can set the default language in the registry.

Check the MUI documentation (Settings for registry storage of selected language).
If you want your users to be able select another language, define MUI_LANGDLL_ALWAYSSHOW as well.
Got it! Thank you very much! Here is corrected example if anyone will need:
Function .onInit
WriteRegDWORD HKLM "Software\MyMegaApplication" "NSISDefaultLang" ${LANG_RUSSIAN}
!define MUI_LANGDLL_REGISTRY_ROOT HKLM
!define MUI_LANGDLL_REGISTRY_KEY "Software\MyMegaApplication"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSISHardcodedDefaultLang"
!define MUI_LANGDLL_ALWAYSSHOW
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd