Search code examples
installationnsisappinstaller

Install the right file with the same name depending on the app's language in NSIS


The installer detects the language of the installed apps, let's say $detected_language will have a value of "pl".

Now I want that only one menu.cfg file is installed, based on the value of $detected_language. Using variables in File ... is not allowed. Is the only way to create lot of Sections, and name them "Kardaw Mod (English)", "Kardaw Mod (German)", etc., and hide all unnecessary Sections with flags which doesn't match the detected language? (menu.cfg cannot be modified on the fly, because it's encrypted).

var detected_language
...

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE detect_app_language; /*$detected_language → "pl"*/
!insertmacro MUI_PAGE_DIRECTORY
...

Section "Kardaw Mod"
  SetOutPath "$INSTDIR\data"
  File "E:\MyMods\Kardaw Mod\English\data\menu.cfg"
  File "E:\MyMods\Kardaw Mod\German\data\menu.cfg"
  File "E:\MyMods\Kardaw Mod\French\data\menu.cfg"
  File "E:\MyMods\Kardaw Mod\Spanish\data\menu.cfg"
  File "E:\MyMods\Kardaw Mod\Russian\data\menu.cfg"
  File "E:\MyMods\Kardaw Mod\Polish\data\menu.cfg";/* ←this one is the correct one */

Solution

  • First thought was to make these entries invisible in a group. But the - symbol was still visible, and the title of the section group had a greyed out checkmark ☑ if it was checked.

    The solution for my question will be placing all the sections one by one. A function will check the right box when we leave the page. It will also check if the mod was selected.

    Wrong Solution Right Solution