当我在德语语言环境中运行安装程序时,安装程序UI会以德语显示,而应用程序UI不会以德语显示。而是以英语显示。
为了使安装程序UI能够按语言环境工作,我创建了单独的.nsh文件(!include“ CustomEnglish.nsh”,!include“ CustomGerman.nsh”,!include“ CustomItalian.nsh”),并将这些文件包含在我的.nsi文件。因此它按预期工作。
为了使应用程序UI能够按语言环境工作,我基于语言使用以下检查,并将文件(为每种语言创建单独的资源dll)放置在Installed目录中。
${If} $Language == 1033 ; English Locale(1033)
File "C:\Desktop\English\license.rtf"
File "C:\Desktop\English\APC PCPE.chm"
File "C:\Desktop\English\AllowStandby.reg"
File "C:\Desktop\English\pchuteres.dll"
File "C:\Desktop\English\relnotes.txt"
File "C:\Desktop\English\res.dll"
${ElseIf} $Language = 1036 ;French Locale(1036)
File "C:\Desktop\French\license.rtf"
File "C:\Desktop\French\APC PCPE.chm"
File "C:\Desktop\French\AllowStandby.reg"
File "C:\Desktop\French\pchuteres.dll"
File "C:\Desktop\French\relnotes.txt"
File "C:\Desktop\French\res.dll"
是否是根据语言环境将dll或文件放置在Installed目录中的正确方法?
而且我也没有在此.nsi文件中使用!insertmacro MUI_LANGUAGE“ English”语句。因为我在!include“ CustomEnglish.nsh”中给出了此语句(我还附加了CustomEnglish.nsh作为参考)
请帮助我为什么应用程序UI不会以德语显示?
以下是完整的代码:
!include "MUI2.nsh"
!include x64.nsh
!include WinVer.nsh
Name "Millinnium 4.0"
OutFile "PCPE_4.0.1.exe"
; The default installation directory in the path C:\Program Files\APC\Millinnium
InstallDir "$PROGRAMFILES32\APC\Millinnium"
InstallDirRegKey HKLM "Software\APC\Millinnium" "Install_Dir"
RequestExecutionLevel admin
;RequestExecutionLevel user
; Below is the include file to check the conditions (If and else)
!include LogicLib.nsh
;Customizing the Welcome Text
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "C:\Program Files (x86)\NSIS\Docs\Modern UI\license.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
!include "CustomEnglish.nsh"
!include "CustomGerman.nsh"
!include "CustomItalian.nsh"
!include "CustomFrench.nsh"
;--------------------------------
;Languages
;!insertmacro MUI_LANGUAGE "English" ; The first language is the default language
;--------------------------------
; The stuff to install
Section "Millinnium (required)"
SectionIn RO
SetOutPath $INSTDIR
; Registry Entries for the 4.01.00 Folder
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00" "AppName" "EMR.exe"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00" "InstallPath" "C:\Program Files\APC\Millinnium\"
${If} ${RunningX64}
MessageBox MB_OK "64-bit windows"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00" "InstallPath" "C:\Program Files (x86)\APC\Millinnium\"
${Else}
MessageBox MB_OK "32-bit windows"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00" "InstallPath" "C:\Program Files\APC\Millinnium\"
${EndIf}
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00" "ResourceFile" "res.dll"
WriteRegDWORD HKLM "SOFTWARE\APC\Millinnium\4.01.00" "UpdateProduct" "0"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00" "Version" "4.0.1"
; Adding Registry entries under "Dialog"
WriteRegDWORD HKLM "SOFTWARE\APC\Millinnium\4.01.00\Dialog" "AppDataCollectionDlg" "0"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00\Dialog" "ReplaceBatteryWebPage" "http://www.APC.com/tools/upgrade_selector/index.cfm?Localize=true"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00\Dialog" "UpgradeUpsUrl" "http://www.APC.com/tools/upgrade_selector/index.cfm?Localize=true"
; Adding Registry entries under "EventLogging"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00\EventLogging" "ImagePath" "C:\Program Files\APC\Millinnium\eventlog.dat"
; Adding Registry entries under "Notifications"
WriteRegDWORD HKLM "SOFTWARE\APC\Millinnium\4.01.00\Notification" "Notification Sounds Enabled" "1"
; Adding Registry entries under "Service"
WriteRegStr HKLM "SOFTWARE\APC\Millinnium\4.01.00\Service" "Image" "mainserv.exe"
${If} ${RunningX64}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "Display" "C:\Program Files (x86)\APC\Millinnium\DataCollectionLauncher.exe"
${Else}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "Display" "C:\Program Files\APC\Millinnium\DataCollectionLauncher.exe"
${EndIf}
WriteUninstaller "uninstall.exe"
System::Call 'KERNEL32::AddDllDirectory(w "$INSTDIR")'
File "C:\Desktop\Common\mainserv.exe"
File "C:\Desktop\Common\Microsoft.VC80.CRT.manifest"
File "C:\Desktop\Common\MsgDll.dll"
File "C:\Desktop\Common\msvcm80.dll"
File "C:\Desktop\Common\msvcp80.dll"
File "C:\Desktop\Common\msvcr80.dll"
File "C:\Desktop\Common\ntutil.dll"
File "C:\Desktop\Common\NTUtil64.exe"
File "C:\Desktop\Common\PCPELog.txt"
File "C:\Desktop\Common\PCPELogger.dll"
${If} $Language == 1033 ; English Locale(1033)
File "C:\Desktop\English\license.rtf"
File "C:\Desktop\English\APC PCPE.chm"
File "C:\Desktop\English\AllowStandby.reg"
File "C:\Desktop\English\pchuteres.dll"
File "C:\Desktop\English\relnotes.txt"
File "C:\Desktop\English\res.dll"
${ElseIf} $Language = 1036 ;French Locale(1036)
File "C:\Desktop\French\license.rtf"
File "C:\Desktop\French\APC PCPE.chm"
File "C:\Desktop\French\AllowStandby.reg"
File "C:\Desktop\French\pchuteres.dll"
File "C:\Desktop\French\relnotes.txt"
File "C:\Desktop\French\res.dll"
${ElseIf} $Language = 1031 ;German Locale(1031)
File "C:\Desktop\German\license.rtf"
File "C:\Desktop\German\APC PCPE.chm"
File "C:\Desktop\German\AllowStandby.reg"
File "C:\Desktop\German\pchuteres.dll"
File "C:\Desktop\German\relnotes.txt"
File "C:\Desktop\German\res.dll"
${ElseIf} $Language = 1040 ;Italian Locale(1040)
File "C:\Desktop\Italian\license.rtf"
File "C:\Desktop\Italian\APC PCPE.chm"
File "C:\Desktop\Italian\AllowStandby.reg"
File "C:\Desktop\Italian\pchuteres.dll"
File "C:\Desktop\Italian\relnotes.txt"
File "C:\Desktop\Italian\res.dll"
${EndIf}
SectionEnd
;--------------------------------
Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\APC"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\APC\Millinnium"
DeleteRegKey HKLM "SOFTWARE\APC\Millinnium"
DeleteRegKey HKLM "SOFTWARE\APC"
SectionEnd
CustomEnglish.nsh
!insertmacro MUI_LANGUAGE "English"
!define ApplicationName "Millinnium"
LangString welcometitle ${LANG_ENGLISH} "Welcome to the ${ApplicationName} Setup Wizard"
LangString welcometext ${LANG_ENGLISH} "The Setup Wizard will install ${ApplicationName} on$\r$\nyour computer. Click Next to continue or Cancel to exit the$\r$\nSetup Wizard."
LangString licensetitle ${LANG_ENGLISH} "End-User License Agreement"
LangString licensesubtitle ${LANG_ENGLISH} "Please read the following license agreement carefully"
LangString licensecheckboxtext ${LANG_ENGLISH} "I &agree to terms in the License Agreement"
LangString mydirtoptext ${LANG_ENGLISH} "Install ${ApplicationName} to:"
LangString mydirtitle ${LANG_ENGLISH} "Destination Folder"
LangString mydirsubtitle ${LANG_ENGLISH} "Click Next to install to the default folder or click Browse to choose another"
答案 0 :(得分:0)
我发现未以其他语言(例如法语)显示UI的根本原因。这是因为我没有在“ INSTDIR”中包括特定于语言的文件夹(例如,具有resources.dll的“ fr”文件夹)。
包括以下几行代码,它现在可以正常工作了:
SetOutPath $INSTDIR\fr
File /a /r "C:\Code\EMR\bin\x86\Release\fr\"