NSIS多语言安装或升级示例
侧边栏壁纸
  • 累计撰写 29 篇文章
  • 累计收到 76 条评论

NSIS多语言安装或升级示例

nsisfans
2022-01-15 / 0 评论 / 65 阅读 / 正在检测是否收录...

#Unicode true
#By:贾可

!include MUI2.nsh

Name "Example"
Caption "Example"

OutFile "Example.exe"

InstallDir $TEMP

!define MUI_LANGDLL_ALWAYSSHOW
!define MUI_LANGDLL_ALLLANGUAGES

!define MUI_CUSTOMFUNCTION_GUIINIT onGUIInit

!define MUI_PAGE_CUSTOMFUNCTION_PRE VerifyUpdateMode
!insertmacro MUI_PAGE_WELCOME

!define MUI_PAGE_CUSTOMFUNCTION_PRE VerifyUpdateMode
!insertmacro MUI_PAGE_DIRECTORY

Var Instfiles.Header.Text
Var Instfiles.Header.SubText
Var Instfiles.Finish.Text
Var Instfiles.Finish.SubText
Var Instfiles.Abort.Text
Var Instfiles.Abort.SubText
Var Instfiles.Mode

!define MUI_PAGE_HEADER_TEXT                   "$Instfiles.Header.Text"
!define MUI_PAGE_HEADER_SUBTEXT                "$Instfiles.Header.SubText"
!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT    "$Instfiles.Finish.Text"
!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "$Instfiles.Finish.SubText"
!define MUI_INSTFILESPAGE_ABORTHEADER_TEXT     "$Instfiles.Abort.Text"
!define MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT  "$Instfiles.Abort.SubText"

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE SimpChinese
!insertmacro MUI_LANGUAGE English

LangString Update.Prompt.Text    ${LANG_SimpChinese} "点击“是”执行初次安装操作,点击“否”执行覆盖升级操作。"

LangString Update.Header.Text    ${LANG_SimpChinese} "正在升级"
LangString Update.Header.SubText ${LANG_SimpChinese} "$(^NameDA) 正在升级,请稍候。"
LangString Update.Finish.Text    ${LANG_SimpChinese} "升级完成"
LangString Update.Finish.SubText ${LANG_SimpChinese} "升级程序已成功地运行完成。"
LangString Update.Abort.Text     ${LANG_SimpChinese} "升级己中止"
LangString Update.Abort.SubText  ${LANG_SimpChinese} "升级程序未成功地运行完成。"

LangString Update.Prompt.Text    ${LANG_English} "Please click $\"Yes$\" to perform installation, or $\"No$\" to perform update."

LangString Update.Header.Text    ${LANG_English} "Updating"
LangString Update.Header.SubText ${LANG_English} "Please wait while $(^NameDA) is being updated."
LangString Update.Finish.Text    ${LANG_English} "Update Complete"
LangString Update.Finish.SubText ${LANG_English} "Setup was completed successfully."
LangString Update.Abort.Text     ${LANG_English} "Update Aborted"
LangString Update.Abort.SubText  ${LANG_English} "Setup was not completed successfully."

ShowInstDetails show

Section "-Install"

  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100
  Sleep 100

SectionEnd

Function .onInit

  !insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd

Function onGUIInit

  ${If} ${Cmd} `MessageBox MB_ICONINFORMATION|MB_YESNO "$(Update.Prompt.Text)" /SD IDYES IDNO`
    StrCpy $Instfiles.Header.Text    "$(Update.Header.Text)"
    StrCpy $Instfiles.Header.SubText "$(Update.Header.SubText)"
    StrCpy $Instfiles.Finish.Text    "$(Update.Finish.Text)"
    StrCpy $Instfiles.Finish.SubText "$(Update.Finish.SubText)"
    StrCpy $Instfiles.Abort.Text     "$(Update.Abort.Text)"
    StrCpy $Instfiles.Abort.SubText  "$(Update.Abort.SubText)"
    StrCpy $Instfiles.Mode 1
  ${Else}
    StrCpy $Instfiles.Header.Text    "$(MUI_TEXT_INSTALLING_TITLE)"
    StrCpy $Instfiles.Header.SubText "$(MUI_TEXT_INSTALLING_SUBTITLE)"
    StrCpy $Instfiles.Finish.Text    "$(MUI_TEXT_FINISH_TITLE)"
    StrCpy $Instfiles.Finish.SubText "$(MUI_TEXT_FINISH_SUBTITLE)"
    StrCpy $Instfiles.Abort.Text     "$(MUI_TEXT_ABORT_TITLE)"
    StrCpy $Instfiles.Abort.SubText  "$(MUI_TEXT_ABORT_SUBTITLE)"
  ${EndIf}

FunctionEnd

Function VerifyUpdateMode

  ${If} $Instfiles.Mode <> 0
    Abort
  ${EndIf}

FunctionEnd
0

评论 (0)

取消