Allow NSIS installer localization

This commit is contained in:
hensm
2020-07-03 02:48:22 +01:00
parent ce7e083ab0
commit cd26f1887b
2 changed files with 44 additions and 13 deletions

View File

@@ -41,3 +41,21 @@ Missing/outdated strings:
* `optionsUserAgentWhitelistRestrictedEnabled` * `optionsUserAgentWhitelistRestrictedEnabled`
* `optionsUserAgentWhitelistRestrictedEnabledDescription` * `optionsUserAgentWhitelistRestrictedEnabledDescription`
* `optionsOptionRecommended` * `optionsOptionRecommended`
### NSIS Installer Localization
If you're comfortable editing and compiling NSIS installer scripts, use the following guide, otherwise just provide translated strings in an issue or PR comment.
To localize Windows installer strings, first add the relevant `MUI_LANGUAGE` macro to the end of the existing list (list of language names can be found [here](https://sourceforge.net/p/nsis/code/HEAD/tree/NSIS/trunk/Contrib/Language%20files/)):
````nsi
!insertmacro MUI_LANGUAGE "German"
````
Then, provide each version of the existing `LangString` commands with that language grouped under the existing strings:
````nsi
LangString MSG__EXAMPLE_STRING1 ${LANG_GERMAN} "Hallo"
LangString MSG__EXAMPLE_STRING2 ${LANG_GERMAN} "Welt"
````
Try to keep the line length under 80 characters by splitting lines within the string with a backslash at the end of the line and a double indent on the next line. To escape characters (like other double quotes), prepend with a `$\`.

View File

@@ -1,8 +1,18 @@
Unicode True Unicode True
SetCompressor /SOLID LZMA SetCompressor /SOLID LZMA
# Registry keys
!define KEY_MANIFEST "Software\Mozilla\NativeMessagingHosts\{{applicationName}}"
!define KEY_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\{{winRegistryKey}}"
!include MUI2.nsh !include MUI2.nsh
# Save installer language for uninstallation
!define MUI_LANGDLL_REGISTRY_ROOT HKLM
!define MUI_LANGDLL_REGISTRY_KEY "${KEY_MANIFEST}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
# MUI general # MUI general
!define MUI_ABORTWARNING !define MUI_ABORTWARNING
@@ -17,12 +27,18 @@ SetCompressor /SOLID LZMA
!insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_UNPAGE_FINISH
# Translator note: see CONTRIBUTING for more info on how to
# translate NSIS installer strings.
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
LangString MSG__INSTALL_BONJOUR ${LANG_ENGLISH} \
# Registry keys "Install Bonjour dependency?"
!define KEY_MANIFEST "Software\Mozilla\NativeMessagingHosts\{{applicationName}}" LangString MSG__FIREFOX_OPEN ${LANG_ENGLISH} \
!define KEY_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\{{winRegistryKey}}" "Firefox must be closed during uninstallation if the extension \
is installed. Close Firefox and click $\"Retry$\", click \
$\"Ignore$\" to force close or $\"Abort$\" to cancel \
uninstallation."
# Application name # Application name
@@ -52,12 +68,12 @@ Section
# Install Bonjour # Install Bonjour
IfFileExists "$SYSDIR\dnssd.dll" skipInstallBonjour IfFileExists "$SYSDIR\dnssd.dll" skipInstallBonjour
MessageBox MB_YESNO \ MessageBox MB_YESNO \
"Install Bonjour dependency?" \ $(MSG__INSTALL_BONJOUR) \
IDNO skipInstallBonjour IDNO skipInstallBonjour
File /oname=Bonjour64.msi "C:\Program Files\Bonjour SDK\Installer\Bonjour64.msi" File /oname=Bonjour64.msi "C:\Program Files\Bonjour SDK\Installer\Bonjour64.msi"
ExecWait "msiexec /i $\"$INSTDIR\Bonjour64.msi$\"" ExecWait "msiexec /i $\"$INSTDIR\Bonjour64.msi$\""
skipInstallBonjour: skipInstallBonjour:
Delete "$INSTDIR\Bonjour64.msi" Delete "$INSTDIR\Bonjour64.msi"
@@ -85,10 +101,7 @@ Section "uninstall"
FindWindow $0 "MozillaWindowClass" FindWindow $0 "MozillaWindowClass"
StrCmp $0 0 continueUninstall StrCmp $0 0 continueUninstall
MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION \ MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION \
"Firefox must be closed during uninstallation if the extension \ $(MSG__FIREFOX_OPEN) \
is installed. Close Firefox and click $\"Retry$\", click \
$\"Ignore$\" to force close or $\"Abort$\" to cancel \
uninstallation." \
IDABORT abortUninstall \ IDABORT abortUninstall \
IDRETRY retryUninstall IDRETRY retryUninstall