Skip to content

Commit

Permalink
[NSIS installer] Update language strings setup
Browse files Browse the repository at this point in the history
Use LANGFILE_INCLUDE_WITHDEFAULT to handle non-translated strings
  • Loading branch information
past-due committed Mar 8, 2020
1 parent 7feda2d commit bba82f1
Show file tree
Hide file tree
Showing 15 changed files with 475 additions and 241 deletions.
6 changes: 0 additions & 6 deletions pkg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
${CMAKE_BINARY_DIR}/NSIS.definitions.nsh
)

# Copy Installer Language files
copyFileToDir("${CMAKE_CURRENT_SOURCE_DIR}/nsis/Lang-English.nsh" "${CMAKE_BINARY_DIR}")
copyFileToDir("${CMAKE_CURRENT_SOURCE_DIR}/nsis/Lang-Dutch.nsh" "${CMAKE_BINARY_DIR}")
copyFileToDir("${CMAKE_CURRENT_SOURCE_DIR}/nsis/Lang-German.nsh" "${CMAKE_BINARY_DIR}")
copyFileToDir("${CMAKE_CURRENT_SOURCE_DIR}/nsis/Lang-Russian.nsh" "${CMAKE_BINARY_DIR}")

# IMPORTANT: To generate the NSIS script, CPack must use `nsis/NSIS.template.in`
list(INSERT CPACK_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/nsis")

Expand Down
53 changes: 0 additions & 53 deletions pkg/nsis/Lang-Dutch.nsh

This file was deleted.

57 changes: 0 additions & 57 deletions pkg/nsis/Lang-English.nsh

This file was deleted.

53 changes: 0 additions & 53 deletions pkg/nsis/Lang-German.nsh

This file was deleted.

53 changes: 0 additions & 53 deletions pkg/nsis/Lang-Russian.nsh

This file was deleted.

28 changes: 18 additions & 10 deletions pkg/nsis/NSIS.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Unicode true
!include "..\..\..\NSIS.definitions.nsh"
!include "${TOP_BUILDDIR}\NSIS.version.nsh"

!include "${TOP_SRCDIR}\pkg\nsis\stringhelpers.nsh"
!include "${TOP_SRCDIR}\pkg\nsis\scripts\stringhelpers.nsh"
!include "${TOP_SRCDIR}\pkg\nsis\scripts\LangFileSpecific.nsh"

;--------------------------------
;Required plugins
Expand Down Expand Up @@ -122,7 +123,11 @@ VIAddVersionKey "ProductVersion" "${PACKAGE_VERSION}"
!define MUI_UNICON "${TOP_SRCDIR}\icons\wz2100portableU.ico"
!endif

!ifndef PORTABLE
!define MUI_WELCOMEPAGE_TEXT "$(WZWelcomeText)"
!else
!define MUI_WELCOMEPAGE_TEXT "$(WZWelcomeText_Portable)"
!endif
!define MUI_ABORTWARNING

!ifndef PORTABLE
Expand Down Expand Up @@ -174,10 +179,18 @@ VIAddVersionKey "ProductVersion" "${PACKAGE_VERSION}"
;--------------------------------
;Languages

!addincludedir "${TOP_SRCDIR}\pkg\nsis\i18n"
!define WZ_LANGFILE_FALLBACK "win_installer_base.nsh"

!insertmacro MUI_LANGUAGE "English" # first language is the default language
!insertmacro LANGFILE_SPECIFIC_INCLUDE "English" "win_installer_base.nsh"

!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro LANGFILE_SPECIFIC_INCLUDE_WITHDEFAULT "Dutch" "win_installer-nl_NL.nsh" ${WZ_LANGFILE_FALLBACK}
!insertmacro MUI_LANGUAGE "German"
!insertmacro LANGFILE_SPECIFIC_INCLUDE_WITHDEFAULT "German" "win_installer-de_DE.nsh" ${WZ_LANGFILE_FALLBACK}
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro LANGFILE_SPECIFIC_INCLUDE_WITHDEFAULT "Russian" "win_installer-ru_RU.nsh" ${WZ_LANGFILE_FALLBACK}

;--------------------------------
;Reserve Files
Expand Down Expand Up @@ -607,21 +620,16 @@ FunctionEnd
;--------------------------------
;Descriptions

!include "..\..\..\Lang-English.nsh"
!include "..\..\..\Lang-Dutch.nsh"
!include "..\..\..\Lang-German.nsh"
!include "..\..\..\Lang-Russian.nsh"

;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Core} "$(DESC_SecBase)"
!insertmacro MUI_DESCRIPTION_TEXT ${Languages} "$(DESC_SecNLS)"

!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs} $(DESC_SecFMVs)
!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_Eng} $(DESC_SecFMVs_Eng)
!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_EngHi} $(DESC_SecFMVs_EngHi)
!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_EngLo} $(DESC_SecFMVs_EngLo)
; !insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_Ger} $(DESC_SecFMVs_Ger)
!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_Eng} "$(DESC_SecFMVs_Eng) (545 MB)"
!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_EngHi} "$(DESC_SecFMVs_EngHi) (920 MB)"
!insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_EngLo} "$(DESC_SecFMVs_EngLo) (162 MB)"
; !insertmacro MUI_DESCRIPTION_TEXT ${SecFMVs_Ger} "$(DESC_SecFMVs_Ger) (460 MB)"

!insertmacro MUI_DESCRIPTION_TEXT ${SecNLS_WinFonts} $(DESC_SecNLS_WinFonts)

Expand Down
37 changes: 37 additions & 0 deletions pkg/nsis/i18n/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
The `win_installer*.nsh` files in this folder are used to define localized additional
strings for the NSIS installers.

The default / base language file is English, at:
[**`win_installer_base.nsh`**](win_installer_base.nsh).
It **must** contain _all_ required strings, and is used as a fallback if other
languages are missing translations / strings.

See: **[/doc/Translations.md](/doc/Translations.md)** for details on how to provide / edit translations.

---

`*.nsh` Language Files Header:

```
; This file is part of Warzone 2100.
; Copyright (C) 2006-2020 Warzone 2100 Project
; Copyright (C) 2006 Dennis Schridde
;
; Warzone 2100 is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; Warzone 2100 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Warzone 2100; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
;
; NSIS Modern User Interface
; Warzone 2100 Project Installer script
;
```

0 comments on commit bba82f1

Please sign in to comment.