Prechádzať zdrojové kódy

feat(nsis-gen): i18n support for custom strings

evshiron 8 rokov pred
rodič
commit
c70d6e369a

+ 9 - 1
README.md

@@ -91,7 +91,15 @@ Also [see all available options here](./docs/Options.md).
 
 ## Development
 
-To be done.
+```bash
+git clone https://github.com/evshiron/nwjs-builder-phoenix
+cd nwjs-builder-phoenix
+npm install
+
+npm test
+```
+
+By the way, I use some custom strings in NSIS scripts which might not be fully translated, if anyone is interested in translating them into languages that aren't available, feel free to fork and send PRs.
 
 ## Available Mirrors
 

+ 1 - 3
src/lib/nsis-gen/Nsis7Zipper.ts

@@ -13,10 +13,8 @@ export class Nsis7Zipper extends NsisComposer {
     protected async makeInstallerFiles(): Promise<string> {
         return `SetOutPath "$INSTDIR"
 SetCompress off
-DetailPrint "Extracting archive..."
 File "${ win32.normalize(resolve(this.path)) }"
-DetailPrint "Installing archive..."
-Nsis7z::ExtractWithDetails "$OUTDIR\\${ basename(this.path) }" "Installing %s..."
+Nsis7z::ExtractWithDetails "$OUTDIR\\${ basename(this.path) }" "$(INSTALLING) %s..."
 Delete "$OUTDIR\\${ basename(this.path) }"`;
     }
 

+ 23 - 2
src/lib/nsis-gen/NsisComposer.ts

@@ -75,6 +75,8 @@ ${ NsisComposer.DIVIDER }
 
 ${ await this.makeGeneralSection() }
 
+${ await this.makeStringsSection() }
+
 ${ await this.makeModernUISection() }
 
 ${ await this.makeVersionSection() }
@@ -121,6 +123,25 @@ RequestExecutionLevel user
 XPStyle on`;
     }
 
+    protected async makeStringsSection(): Promise<string> {
+        return `${ NsisComposer.DIVIDER }
+#
+# Strings
+#
+${ NsisComposer.DIVIDER }
+
+# FIXME: More translations.
+
+LangString CREATE_DESKTOP_SHORTCUT 1033 "Create Desktop Shortcut"
+LangString CREATE_DESKTOP_SHORTCUT 2052 "创建桌面快捷方式"
+LangString CREATE_DESKTOP_SHORTCUT 1028 "建立桌面捷徑"
+
+LangString INSTALLING 1033 "Installing"
+LangString INSTALLING 2052 "正在安装"
+LangString INSTALLING 1028 "安裝中"
+`;
+    }
+
     protected async makeModernUISection(): Promise<string> {
         return `${ NsisComposer.DIVIDER }
 #
@@ -139,7 +160,7 @@ FunctionEnd
 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder"
 
 !define MUI_FINISHPAGE_SHOWREADME ""
-!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
+!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(CREATE_DESKTOP_SHORTCUT)"
 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut
 
 Var StartMenuFolder
@@ -241,7 +262,7 @@ ${ NsisComposer.DIVIDER }
 
 Section Uninstall
 
-# FIXME: Remove only files installed.
+# FIXME: Remove installed files only.
 RMDir /r "$INSTDIR"
 
 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $StartMenuFolder