0
votes

Looking to change the SectionIn for a section based on what language the user selects. So if the "Standard" install is 1 and "Full" install is 2, I want it so that if the user selects English then the "English Documentation" section has SectionIn 1 2, but if they select something else like French, then "English Documentation" is SectionIn 2 and "French Documentation" is SectionIn 1 2.

The goal is to have both language documentations selectable no matter what, but based on the language one is the default and InstType drop down box will show "Standard" instead of custom (I already know how to make it select one or the other based on the language selection). Here's basically what I'm working with to change the selection at least:

    InstType "Standard"
    InstType "Full"

    Section /o "English Docs" English
    SectionIn 2
    ;crap to run
    SectionEnd

    Section /o "French Docs" French
    SectionIn 2
    ;crap to run
    SectionEnd


    Function .onInit
    !insertmacro MUI_LANGDLL_DISPLAY
    ${If} $LANGUAGE == ${LANG_ENGLISH}
    !insertmacro SelectSection ${English}
    ${EndIf}
    ${If} $LANGUAGE == ${LANG_FRENCH}
    !insertmacro SelectSection ${French}
    ${EndIf}
    FunctionEnd
1
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. So, what did you tried? - Seki
I've seen this done in other NSIS installers out there, but I can't find any documentation on how it's done, SectionIn apparently won't allow for variables, and if/else commands around it don't work to solve the problem either. - l33tmeatwad
SectionIn is a compile-time attribute. - Anders

1 Answers

0
votes

Use SectionSetInstTypes:

!include MUI2.nsh
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
!insertmacro MUI_LANGUAGE French


InstType "Standard"
InstType "Full"

Section /o "English Docs" SID_English
SectionIn 2
;crap to run
SectionEnd

Section /o "French Docs" SID_French
SectionIn 2
;crap to run
SectionEnd


Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
${If} $LANGUAGE == ${LANG_ENGLISH}
    StrCpy $0 ${SID_English}
${EndIf}
${If} $LANGUAGE == ${LANG_FRENCH}
    StrCpy $0 ${SID_French}
${EndIf}

SectionSetInstTypes $0 3
!insertmacro SelectSection $0
FunctionEnd