Browse Source

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

evshiron 8 years ago
parent
commit
c70d6e369a
3 changed files with 33 additions and 6 deletions
  1. 9 1
      README.md
  2. 1 3
      src/lib/nsis-gen/Nsis7Zipper.ts
  3. 23 2
      src/lib/nsis-gen/NsisComposer.ts

+ 9 - 1
README.md

@@ -91,7 +91,15 @@ Also [see all available options here](./docs/Options.md).
 
 
 ## Development
 ## 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
 ## Available Mirrors
 
 

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

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

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

@@ -75,6 +75,8 @@ ${ NsisComposer.DIVIDER }
 
 
 ${ await this.makeGeneralSection() }
 ${ await this.makeGeneralSection() }
 
 
+${ await this.makeStringsSection() }
+
 ${ await this.makeModernUISection() }
 ${ await this.makeModernUISection() }
 
 
 ${ await this.makeVersionSection() }
 ${ await this.makeVersionSection() }
@@ -121,6 +123,25 @@ RequestExecutionLevel user
 XPStyle on`;
 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> {
     protected async makeModernUISection(): Promise<string> {
         return `${ NsisComposer.DIVIDER }
         return `${ NsisComposer.DIVIDER }
 #
 #
@@ -139,7 +160,7 @@ FunctionEnd
 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder"
 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder"
 
 
 !define MUI_FINISHPAGE_SHOWREADME ""
 !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
 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut
 
 
 Var StartMenuFolder
 Var StartMenuFolder
@@ -241,7 +262,7 @@ ${ NsisComposer.DIVIDER }
 
 
 Section Uninstall
 Section Uninstall
 
 
-# FIXME: Remove only files installed.
+# FIXME: Remove installed files only.
 RMDir /r "$INSTDIR"
 RMDir /r "$INSTDIR"
 
 
 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $StartMenuFolder
 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $StartMenuFolder