Search code examples
nsismultilingual

How to set a default language on select language dialog?


I have my .nis like this:

## Languages (first language is the default language)
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "Dutch"

I read the manual and it says:

first language is the default language

If I don't use English that works correctly, if I use English that is always the default language:

enter image description here

How I can change the default language?


Solution

  • There are 3 steps involved in selecting the default language for the language picker dialog.

    1. At startup NSIS tries to initialize $Language with the language id of the UI language the user is using. This happens before the .onInit callback is called.
    2. If you are using the MUI and have set the MUI_LANGDLL_REGISTRY_* defines and they are found in the registry then $Language is forced to that language in the MUI_LANGDLL_DISPLAY macro. Remove the defines if you don't want this behavior or define MUI_LANGDLL_ALWAYSSHOW to let the user override it.
    3. The LangDLL plugin will filter out some of the languages if it thinks there is a codepage problem (in ANSI installers). This can be turned off by defining MUI_LANGDLL_ALLLANGUAGES.

    If you want to ignore step 1 then you have to force the language on your own:

    Function .onInit
        StrCpy $Language ${LANG_FRENCH}
        !insertmacro MUI_LANGDLL_DISPLAY
    FunctionEnd