Skip to content
⌘ NSIS Forum Archive

NSIS - custom language

4 posts

thughaz#

NSIS - custom language

Hi,
I want to create custom installer by NSIS, my nsis config file (Base.nsh) looks like:

Name "${ZIP2EXE_NAME}"
OutFile "${ZIP2EXE_OUTFILE}"
AllowRootDirInstall true
!insertmacro MUI_LANGUAGE "German"
!ifdef ZIP2EXE_COMPRESSOR_SOLID
  !define SETCOMPRESSOR_SWITCH /SOLID
!else
  !define SETCOMPRESSOR_SWITCH
!endif
!ifdef ZIP2EXE_COMPRESSOR_ZLIB
  SetCompressor ${SETCOMPRESSOR_SWITCH} zlib
!else ifdef ZIP2EXE_COMPRESSOR_BZIP2
  SetCompressor ${SETCOMPRESSOR_SWITCH} bzip2
!else ifdef ZIP2EXE_COMPRESSOR_LZMA
  SetCompressor ${SETCOMPRESSOR_SWITCH} lzma
!endif
!ifdef ZIP2EXE_INSTALLDIR
  InstallDir "${ZIP2EXE_INSTALLDIR}"
  Function zip2exe.SetOutPath
    
        SetOutPath "$INSTDIR"
  FunctionEnd
!else ifdef ZIP2EXE_INSTALLDIR_WINAMP
  InstallDir "$PROGRAMFILES\Winamp"
  InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString"
  Function .onVerifyInstDir
    IfFileExists $INSTDIR\winamp.exe WinampInstalled
      Abort
    WinampInstalled:
  FunctionEnd
  !ifdef ZIP2EXE_INSTALLDIR_WINAMPMODE
 
    Var ZIP2EXE_TEMP1
    Var ZIP2EXE_TEMP2
    Function zip2exe.SetOutPath
       !ifdef ZIP2EXE_INSTALLDIR_SKINS
         StrCpy $ZIP2EXE_TEMP1 "$INSTDIR\Skins"
       !else
         StrCpy $ZIP2EXE_TEMP1 "$INSTDIR\Plugins"
       !endif
       ReadINIStr $ZIP2EXE_TEMP2 "$INSTDIR\winamp.ini" "Winamp" "${ZIP2EXE_INSTALLDIR_WINAMPMODE}"
         StrCmp $ZIP2EXE_TEMP2 "" End
         IfFileExists $ZIP2EXE_TEMP2 0 End
         StrCpy $ZIP2EXE_TEMP1 $ZIP2EXE_TEMP2
       End:
         SetOutPath $ZIP2EXE_TEMP1
    FunctionEnd
  !else
    Function zip2exe.SetOutPath
      !ifdef ZIP2EXE_INSTALLDIR_PLUGINS
        SetOutPath "$INSTDIR\Plugins"
      !else
        SetOutPath "$INSTDIR"
      !endif
    FunctionEnd
  !endif
!endif
!macro SECTION_BEGIN
  Section ""
    Call zip2exe.SetOutPath
!macroend
!macro SECTION_END
SectionEnd
Section "Create Shortcuts"
        SetShellVarContext all
        CreateShortCut "$DESKTOP\Skrot.lnk" "$INSTDIR\Binaries\Win32\UDK.exe"
        WriteUninstaller "$INSTDIR\uninstall.exe"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Namee\Name1" "DisplayName" "Name"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Namee\Name1" "UninstallString" "$INSTDIR\uninstall.exe"
SectionEnd
Section "Redistributable Prerequisites"
        SetShellVarContext all
      
        DetailPrint "Starting the Redistributable Prerequisites Setup..."
        ExecWait "$INSTDIR\Binaries\Redist\UE3Redist.exe"
SectionEnd
Section "Uninstall"
        SetShellVarContext all
     
        Delete "$DESKTOP\Skrot.lnk"
      
        RMDir /r "$INSTDIR"
        Delete $INSTDIR\uninstall.exe
SectionEnd
!macroend 
the point of problem is installer language. Above code resulting error:

!insertmacro: macro named "MUI_LANGUAGE" not found!
!include: error in script: "G:\Program Files (x86)\NSIS\Contrib\zip2exe\Base.nsh" on line 14
Error in script "C:\Users\hazeh\AppData\Local\Temp\zne28FA.tmp" on line 6 -- aborting creation process
(source ZIP size was 3126998 bytes) 
Just don't know how to set (in my script) German as installer lang. NSIS Version: 3.0a2
Afrow UK#
!include MUI2.nsh

Edit: You will also need to insert at least one MUI page before the MUI_LANGUAGE insert. Look at the example scripts.

Stu
thughaz#
Do you mean something like that?

!include "MUI2.nsh"
Name "${ZIP2EXE_NAME}"
OutFile "${ZIP2EXE_OUTFILE}"
AllowRootDirInstall true
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_LANGUAGE "German"
!ifdef ZIP2EXE_COMPRESSOR_SOLID
  !define SETCOMPRESSOR_SWITCH /SOLID
!else
  !define SETCOMPRESSOR_SWITCH
!endif
!ifdef ZIP2EXE_COMPRESSOR_ZLIB
  SetCompressor ${SETCOMPRESSOR_SWITCH} zlib
!else ifdef ZIP2EXE_COMPRESSOR_BZIP2
  SetCompressor ${SETCOMPRESSOR_SWITCH} bzip2
!else ifdef ZIP2EXE_COMPRESSOR_LZMA
  SetCompressor ${SETCOMPRESSOR_SWITCH} lzma
!endif
!ifdef ZIP2EXE_INSTALLDIR
  InstallDir "${ZIP2EXE_INSTALLDIR}"
  Function zip2exe.SetOutPath
    
        SetOutPath "$INSTDIR"
  FunctionEnd
!else ifdef ZIP2EXE_INSTALLDIR_WINAMP
  InstallDir "$PROGRAMFILES\Winamp"
  InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" "UninstallString"
  Function .onVerifyInstDir
    IfFileExists $INSTDIR\winamp.exe WinampInstalled
      Abort
    WinampInstalled:
  FunctionEnd
  !ifdef ZIP2EXE_INSTALLDIR_WINAMPMODE
 
    Var ZIP2EXE_TEMP1
    Var ZIP2EXE_TEMP2
    Function zip2exe.SetOutPath
       !ifdef ZIP2EXE_INSTALLDIR_SKINS
         StrCpy $ZIP2EXE_TEMP1 "$INSTDIR\Skins"
       !else
         StrCpy $ZIP2EXE_TEMP1 "$INSTDIR\Plugins"
       !endif
       ReadINIStr $ZIP2EXE_TEMP2 "$INSTDIR\winamp.ini" "Winamp" "${ZIP2EXE_INSTALLDIR_WINAMPMODE}"
         StrCmp $ZIP2EXE_TEMP2 "" End
         IfFileExists $ZIP2EXE_TEMP2 0 End
         StrCpy $ZIP2EXE_TEMP1 $ZIP2EXE_TEMP2
       End:
         SetOutPath $ZIP2EXE_TEMP1
    FunctionEnd
  !else
    Function zip2exe.SetOutPath
      !ifdef ZIP2EXE_INSTALLDIR_PLUGINS
        SetOutPath "$INSTDIR\Plugins"
      !else
        SetOutPath "$INSTDIR"
      !endif
    FunctionEnd
  !endif
!endif
!macro SECTION_BEGIN
  Section ""
    Call zip2exe.SetOutPath
!macroend
!macro SECTION_END
SectionEnd
Section "Create Shortcuts"
        SetShellVarContext all
        CreateShortCut "$DESKTOP\Skrot.lnk" "$INSTDIR\Binaries\Win32\UDK.exe"
        WriteUninstaller "$INSTDIR\uninstall.exe"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Namee\Name1" "DisplayName" "Name"
        WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Namee\Name1" "UninstallString" "$INSTDIR\uninstall.exe"
SectionEnd
Section "Redistributable Prerequisites"
        SetShellVarContext all
      
        DetailPrint "Starting the Redistributable Prerequisites Setup..."
        ExecWait "$INSTDIR\Binaries\Redist\UE3Redist.exe"
SectionEnd
Section "Uninstall"
        SetShellVarContext all
     
        Delete "$DESKTOP\Skrot.lnk"
      
        RMDir /r "$INSTDIR"
        Delete $INSTDIR\uninstall.exe
SectionEnd
!macroend 
it returns:
Error: can't change compressor after data already got compressed or header already changed!
!include: error in script: "G:\Program Files (x86)\NSIS\Contrib\zip2exe\Base.nsh" on line 26
Error in script "C:\Users\hazeh\AppData\Local\Temp\zne2CCB.tmp" on line 6 -- aborting creation process 
JasonFriday13#
The MUI stuff should be after the compressor settings, not before them (that's why you got that error).