NSIS: Possibility to include translated license and README.txt files (#14311)

* NSIS: Possibility to include translated license and README.txt files
* fixed a missing semicolon
* Disable always show dialog choice language

Signed-off-by: RestorerZ <restorer@mail2k.ru>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/nsis/README.txt b/nsis/README.txt
index c0b0376..79c1952 100644
--- a/nsis/README.txt
+++ b/nsis/README.txt
@@ -54,8 +54,8 @@
 
 7.  On MS Windows do "nmake.exe -f Make_mvc.mak uganda.nsis.txt" in runtime/doc.
     On Unix-like system do "make runtime/doc/uganda.nsis.txt" in top directory
-    or "make uganda.nsis.txt" in runtime/doc, and be sure to convert the file
-    "uganda.nsis.txt" to DOS file format.
+    or "make uganda.nsis.txt" in runtime/doc.  The created files
+    "uganda.nsis.???" will be automatically converted to DOS file format.
 
 8.  Get gettext and iconv DLLs from the following site:
 	https://github.com/mlocati/gettext-iconv-windows/releases
diff --git a/nsis/gvim.nsi b/nsis/gvim.nsi
index 754e9ca..7d866ff 100644
--- a/nsis/gvim.nsi
+++ b/nsis/gvim.nsi
@@ -1,6 +1,6 @@
 # NSIS file to create a self-installing exe for Vim.
 # It requires NSIS version 3.0 or later.
-# Last Change:	2024 Mar 18
+# Last Change:	2024 Mar 20
 
 Unicode true
 
@@ -157,9 +157,9 @@
 
 !define MUI_COMPONENTSPAGE_SMALLDESC
 !define MUI_LICENSEPAGE_CHECKBOX
-!define MUI_FINISHPAGE_RUN
-!define MUI_FINISHPAGE_RUN_FUNCTION        LaunchApplication
-!define MUI_FINISHPAGE_RUN_TEXT            $(str_show_readme)
+!define MUI_FINISHPAGE_SHOWREADME
+!define MUI_FINISHPAGE_SHOWREADME_TEXT	    $(str_show_readme)
+!define MUI_FINISHPAGE_SHOWREADME_FUNCTION  LaunchApplication
 
 # This adds '\Vim' to the user choice automagically.  The actual value is
 # obtained below with CheckOldVim.
@@ -183,7 +183,7 @@
 
 # Installer pages
 !insertmacro MUI_PAGE_WELCOME
-!insertmacro MUI_PAGE_LICENSE "${VIMRT}\doc\uganda.nsis.txt"
+!insertmacro MUI_PAGE_LICENSE $(page_lic_file)
 !insertmacro MUI_PAGE_COMPONENTS
 Page custom SetCustom ValidateCustom
 #!define MUI_PAGE_CUSTOMFUNCTION_LEAVE VimFinalCheck
@@ -365,7 +365,7 @@
 
 Function LaunchApplication
    SetOutPath $0
-   ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\README.txt"'
+   ShellExecAsUser::ShellExecAsUser "" "$0\gvim.exe" '-R "$0\$(vim_readme_file)"'
 FunctionEnd
 
 ##########################################################
@@ -615,6 +615,110 @@
 Section "$(str_section_nls)" id_section_nls
 	SectionIn 1 3
 
+#; FIXME: When adding new translations, do not forget to make changes here.
+	SetOutPath $0
+!if /FileExists ..\README.dax.txt
+    ${If} $Language = ${LANG_DANISH}
+	File ..\README.dax.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.nlx.txt
+    ${If} $Language = ${LANG_DUTCH}
+	File ..\README.nlx.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.dex.txt
+    ${If} $Language = ${LANG_GERMAN}
+	File ..\README.dex.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.itx.txt
+    ${If} $Language = ${LANG_ITALIAN}
+	File ..\README.itx.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.jax.txt
+    ${If} $Language = ${LANG_JAPANESE}
+	File ..\README.jax.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.rux.txt
+    ${If} $Language = ${LANG_RUSSIAN}
+	File ..\README.rux.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.srx.txt
+    ${If} $Language = ${LANG_SERBIAN}
+	File ..\README.srx.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.cnx.txt
+    ${If} $Language = ${LANG_SIMPCHINESE}
+	File ..\README.cnx.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.twx.txt
+    ${If} $Language = ${LANG_TRADCHINESE}
+	File ..\README.twx.txt
+    ${EndIf}
+!endif
+!if /FileExists ..\README.trx.txt
+    ${OrIf} $Language = ${LANG_TURKISH}
+	File ..\README.trx.txt
+    ${EndIf}
+!endif
+#; FIXME: When adding new translations, do not forget to make changes here.
+	SetOutPath $0\doc
+!if /FileExists "${VIMRT}\doc\uganda.dax"
+    ${If} $Language = ${LANG_DANISH}
+	File ${VIMRT}\doc\uganda.dax
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.nlx"
+    ${If} $Language = ${LANG_DUTCH}
+	File ${VIMRT}\doc\uganda.nlx
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.dex"
+    ${If} $Language = ${LANG_GERMAN}
+	File ${VIMRT}\doc\uganda.dex
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.itx"
+    ${If} $Language = ${LANG_ITALIAN}
+	File ${VIMRT}\doc\uganda.itx
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.jax"
+    ${If} $Language = ${LANG_JAPANESE}
+	File ${VIMRT}\doc\uganda.jax
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.rux"
+    ${If} $Language = ${LANG_RUSSIAN}
+	File ${VIMRT}\doc\uganda.rux
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.srx"
+    ${If} $Language = ${LANG_SERBIAN}
+	File ${VIMRT}\doc\uganda.srx
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.cnx"
+    ${If} $Language = ${LANG_SIMPCHINESE}
+	File ${VIMRT}\doc\uganda.cnx
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.twx"
+    ${If} $Language = ${LANG_TRADCHINESE}
+	File ${VIMRT}\doc\uganda.twx
+    ${EndIf}
+!endif
+!if /FileExists "${VIMRT}\doc\uganda.trx"
+    ${If} $Language = ${LANG_TURKISH}
+	File ${VIMRT}\doc\uganda.trx
+    ${EndIf}
+!endif
 	SetOutPath $0\lang
 	File /r /x Makefile ${VIMRT}\lang\*.*
 	SetOutPath $0
diff --git a/nsis/lang/README.txt b/nsis/lang/README.txt
new file mode 100644
index 0000000..68ff112
--- /dev/null
+++ b/nsis/lang/README.txt
@@ -0,0 +1,34 @@
+This directory contains a file with text strings for gVim installer.
+It also contains files with translations of the text strings for gVim installer
+into different languages.
+
+For translators.
+
+If you want to prepare a translation for the gVim installer, use the file
+"english.nsi" as a master file.  See the other translation files in this
+directory.
+Note that in the definition of the MUI_LANGUAGE macro, the name of the language
+to be translated must be the English name of the language.
+The name of the file with the translation must match the name of the target
+language.
+Also, when translating strings, pay attention to some restrictions on the
+allowable length of strings.  For example:
+ component description field - 117 characters;
+ description above the drop-down lists on the .vimrc page - 53 characters;
+ drop-down lists on the .vimrc page - 55 characters.
+Characters in this case mean characters of the English alphabet.
+
+If you do not yet have a translated "uganda.txt" file and a main "README.txt"
+file, set the following values:
+
+for the license file
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+
+for the readme.txt file
+LangString vim_readme_file 0 "README.txt"
+
+Once you have the translations of these files, then set the values for these
+variables similarly to what is done in the other translation files.
+Also add the appropriate entries to the "gvim.nsi" file as done for other
+languages.
+
diff --git a/nsis/lang/danish.nsi b/nsis/lang/danish.nsi
index b365413..ceb18be 100644
--- a/nsis/lang/danish.nsi
+++ b/nsis/lang/danish.nsi
@@ -3,6 +3,7 @@
 # danish.nsi: Danish language strings for gvim NSIS installer.
 #
 # Locale ID    : 1030
+# Locale Name  : da
 # fileencoding : UTF-8
 # Author       : scootergrisen
 
@@ -15,6 +16,20 @@
 LangString ^UninstallCaption ${LANG_DANISH}         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_DANISH} "${VIMRT}\doc\uganda.nsis.dax"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_DANISH} "README.dax.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/dutch.nsi b/nsis/lang/dutch.nsi
index 1d13224..49b1ed0 100644
--- a/nsis/lang/dutch.nsi
+++ b/nsis/lang/dutch.nsi
@@ -18,6 +18,20 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_DUTCH} "${VIMRT}\doc\uganda.nsis.nlx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_DUTCH} "README.nlx.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/english.nsi b/nsis/lang/english.nsi
index e1be985..6f69f58 100644
--- a/nsis/lang/english.nsi
+++ b/nsis/lang/english.nsi
@@ -3,6 +3,7 @@
 # english.nsi: English language strings for gvim NSIS installer.
 #
 # Locale ID    : 1033
+# Locale Name  : en
 # fileencoding : UTF-8
 # Author       : Guopeng Wen, Ken Takata
 
@@ -17,6 +18,18 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# License file for the license page                                       {{{1
+##############################################################################
+
+LicenseLangString page_lic_file ${LANG_ENGLISH} "${VIMRT}\doc\uganda.nsis.txt"
+
+##############################################################################
+# README.txt file, which is opened after installation                     {{{1
+##############################################################################
+
+LangString vim_readme_file ${LANG_ENGLISH} "README.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/german.nsi b/nsis/lang/german.nsi
index b976ef4..92b92d9 100644
--- a/nsis/lang/german.nsi
+++ b/nsis/lang/german.nsi
@@ -3,6 +3,7 @@
 # german.nsi : German language strings for gvim NSIS installer.
 #
 # Locale ID    : 1031
+# Locale Name  : de
 # fileencoding : UTF-8
 # Author       : Christian Brabandt, tux
 
@@ -17,6 +18,20 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_GERMAN} "${VIMRT}\doc\uganda.nsis.dex"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_GERMAN} "README.dex.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/greek.nsi b/nsis/lang/greek.nsi
index 5175dd5..b92d3f3 100644
--- a/nsis/lang/greek.nsi
+++ b/nsis/lang/greek.nsi
@@ -3,6 +3,7 @@
 # greek.nsi: Greek language strings for gvim NSIS installer.
 #
 # Locale ID    : 1032
+# Locale Name  : el
 # fileencoding : UTF-8
 # Author       : Christos Longros
 
@@ -17,6 +18,20 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_GREEK} "${VIMRT}\doc\uganda.nsis.elx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_GREEK} "README.elx.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/italian.nsi b/nsis/lang/italian.nsi
index 029737f..5f32680 100644
--- a/nsis/lang/italian.nsi
+++ b/nsis/lang/italian.nsi
@@ -3,6 +3,7 @@
 # italian.nsi : Italian language strings for gvim NSIS installer.
 #
 # Locale ID    : 1040
+# Locale Name  : it
 # fileencoding : UTF-8
 # Author       : Antonio Colombo, bovirus - revision: 12.05.2023
 
@@ -17,6 +18,20 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_ITALIAN} "${VIMRT}\doc\uganda.nsis.itx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_ITALIAN} "README.itx.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/japanese.nsi b/nsis/lang/japanese.nsi
index 58f4dcc..d290355 100644
--- a/nsis/lang/japanese.nsi
+++ b/nsis/lang/japanese.nsi
@@ -3,6 +3,7 @@
 # japanese.nsi: Japanese language strings for gvim NSIS installer.
 #
 # Locale ID    : 1041
+# Locale Name  : ja
 # fileencoding : UTF-8
 # Author       : Ken Takata
 
@@ -27,6 +28,20 @@
         "インストール(&I)"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_JAPANESE} "${VIMRT}\doc\uganda.nsis.jax"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_JAPANESE} "README.jax.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/russian.nsi b/nsis/lang/russian.nsi
index e4b01e3..876bef2 100644
--- a/nsis/lang/russian.nsi
+++ b/nsis/lang/russian.nsi
@@ -3,7 +3,7 @@
 # russian.nsi: Russian language strings for gvim NSIS installer.
 #
 # Locale ID    : 1049
-# Locale name  : ru-RU
+# Locale name  : ru
 # fileencoding : UTF-8
 # Author       : Restorer
 
@@ -18,6 +18,18 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file ${LANG_RUSSIAN} "${VIMRT}\doc\uganda.nsis.rux"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file ${LANG_RUSSIAN} "README.rux.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/serbian.nsi b/nsis/lang/serbian.nsi
index 11d889a..122727d 100644
--- a/nsis/lang/serbian.nsi
+++ b/nsis/lang/serbian.nsi
@@ -3,6 +3,7 @@
 # serbian.nsi: Serbian language strings for gvim NSIS installer.
 #
 # Locale ID    : 3098
+# Locale Name  : sr
 # fileencoding : UTF-8
 # Author       : Ivan Pešić
 
@@ -17,6 +18,20 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_SERBIAN} "${VIMRT}\doc\uganda.nsis.srx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_SERBIAN} "README.srx.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/simpchinese.nsi b/nsis/lang/simpchinese.nsi
index 2c80054..8d2d073 100644
--- a/nsis/lang/simpchinese.nsi
+++ b/nsis/lang/simpchinese.nsi
@@ -4,6 +4,7 @@
 # installer.
 #
 # Locale ID    : 2052
+# Locale Name  : cn
 # fileencoding : UTF-8
 # Author       : Guopeng Wen, David Liu
 
@@ -18,6 +19,21 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_SIMPCHINESE} \
+#        "${VIMRT}\doc\uganda.nsis.cnx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_SIMPCHINESE} "README.cnx.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/tradchinese.nsi b/nsis/lang/tradchinese.nsi
index 16b6747..66bb1b8 100644
--- a/nsis/lang/tradchinese.nsi
+++ b/nsis/lang/tradchinese.nsi
@@ -4,6 +4,7 @@
 # installer.
 #
 # Locale ID    : 1028
+# Locale Name  : tw
 # fileencoding : UTF-8
 # Author       : Guopeng Wen
 
@@ -18,6 +19,21 @@
         "$(^Name) Uninstall"
 
 ##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_TRADCHINESE} \
+#        "${VIMRT}\doc\uganda.nsis.twx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_TRADCHINESE} "README.twx.txt"
+
+##############################################################################
 # MUI Configuration Strings                                               {{{1
 ##############################################################################
 
diff --git a/nsis/lang/turkish.nsi b/nsis/lang/turkish.nsi
index 1046b81..429cbb3 100644
--- a/nsis/lang/turkish.nsi
+++ b/nsis/lang/turkish.nsi
@@ -1,4 +1,9 @@
+# vi:set ts=8 sts=4 sw=4 et fdm=marker:
+#
 # turkish.nsi: Turkish language strings for gvim NSIS installer.
+#
+# Locale ID    : 1055
+# Locale Name  : tr
 # fileencoding : UTF-8
 # Author       : Emir SARI
 
@@ -11,6 +16,22 @@
 LangString ^UninstallCaption ${LANG_TURKISH} \
         "$(^Name) Uninstall"
 
+##############################################################################
+# Translated license file for the license page                            {{{1
+##############################################################################
+
+LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_TURKISH} "${VIMRT}\doc\uganda.nsis.trx"
+
+##############################################################################
+# Translated README.txt file, which is opened after installation          {{{1
+##############################################################################
+
+LangString vim_readme_file 0 "README.txt"
+#LangString vim_readme_file ${LANG_TURKISH} "README.trx.txt"
+
+##############################################################################
+
 LangString str_show_readme          ${LANG_TURKISH} \
     "Kurulum bittikten sonra README dosyasını aç"