标签:option nload windows 卸载 adr 匹配 变量 string 找不到
NSIS官方手册多语言介绍
多语言的使用
NSIS有两种引入多语言的方法,其中:
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Czech.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\Dutch.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\French.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\German.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\Korean.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\Russian.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\Spanish.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\Swedish.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\TradChinese.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\SimpChinese.nlf" LoadLanguageFile "${NSISDIR}\Contrib\Language files\Slovak.nlf"
!include "MUI2.nsh" !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Dutch" !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "Korean" !insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "SimpChinese" ;初始化函数 Function .onInit Push "" Push ${LANG_ENGLISH} ;添加英文代码 语言代码是系统变量,多语言引入后,自动加载,拼接方式是“LANG_语言”,可以查看NSIS手册,LANG_ENGLISH的编号为1033,LANG_SIMPCHINESE为2052; Push "English" Push ${LANG_SIMPCHINESE} ;添加简体中文选项 Push "简体中文" Push A ; A means auto count languages for the auto count to work the first empty push (Push "") must remain LangDLL::LangDialog "Installer Language" "Please select the language of the installer" ;显示语言选择对话框 Pop $LANGUAGE ;获得用户对于语言的选择结果 ‘$LANGUAGE’是多语言变量,在安装程序结束后,语言代码会存储在这个变量中,手动修改‘$LANGUAGE’的值后,安装包会重新选择最匹配的语言,参考最上面NSIS手册中选择界面语言步骤 StrCmp $LANGUAGE "cancel" 0 +2 Abort StrCmp $LANGUAGE 2052 ZH_INI EN_INI EN_INI: ;想干啥干啥 Goto END ZH_INI: ;想干啥干啥 END: FunctionEnd
LangString INFO1 ${LANG_ENGLISH} " Prompt message 1" LangString INFO1 ${LANG_SIMPCHINESE} "提示信息1。 LangString INFO2 ${LANG_ENGLISH} " Prompt message 2" LangString INFO2 ${LANG_SIMPCHINESE} "提示信息2"。
(2)自定义函数中引入多语言提示词
Function CustomPageInitFunc InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\dialog.ini" ;载入界面UI文件 !insertmacro MUI_HEADER_TEXT $(INFO1) $(INFO2) ;自定义界面说明文字,此处引用的 ‘$(INFO1)‘,‘$(INFO2)’是定义的多语言字符串 Pop $hwnd InstallOptions::show ;显示界面 Pop $0 Goto end FunctionEnd
;初始化函数 Function .onInit ;内容见第二小节(二、 提供语言选择对话框) FunctionEnd Section -Post WriteRegStr HKCU ${LANGUAG_FLAG} "language" $LANGUAGE ;保存软件安装时选择的语言 ${LANGUAG_FLAG}是自定义的一个标识字段,可以为任意值 SectionEnd
(2)卸载程序初始化时,获取语言标志,并手动处理多语言
Function un.onInit ReadRegDWORD $LANGUAGE HKCU ${LANGUAG_FLAG} "language" ; 读取注册表获取程序安装时设置的语言 StrCmp $LANGUAGE ${LANG_SIMPCHINESE} ZH EN ; 在un.onInit函数中,多语言只能手动处理 EN: MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name)?" IDYES +2 Abort Goto End ZH: MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "你确实要完全移除 $(^Name)?" IDYES +2 Abort Goto End End: FunctionEnd
(3)卸载过程中使用多语言字符串
Section Uninstall ; 检测程序是否在运行 FindProcDLL::FindProc "${PRODUCT_NAME}.exe" ;检测主程序 IntCmp $R0 1 0 +3 MessageBox MB_ICONSTOP "$(^Name) $(EXE_RUNNING_WARN)" ;此处的$(EXE_RUNNING_WARN)是声明的多语言字符串,声明方法见(第三节 在其他函数中使用多语言-> 声明自定义字符串) Quit ; 做些卸载程序的工作 SectionEnd
附件:NSIS官方中文手册
标签:option nload windows 卸载 adr 匹配 变量 string 找不到
原文地址:https://www.cnblogs.com/donfaquir/p/12676470.html