patch 9.1.1029: the installer can be improved

Problem:  the installer can be improved
Solution: update the installer with the correct README and LICENSE
          files, improve the documentation, add a Makefile for the
          installer, update the Makefiles (RestorerZ)

fixes: #16378
closes: #16378

Signed-off-by: RestorerZ <restorer@mail2k.ru>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/nsis/Make_mvc.mak b/nsis/Make_mvc.mak
new file mode 100644
index 0000000..c5aff15
--- /dev/null
+++ b/nsis/Make_mvc.mak
@@ -0,0 +1,134 @@
+#
+# Makefile for MS Windows for create self-installing exe of Vim.
+# 05/04/2024, Restorer restorer@mail2k.ru
+#
+
+
+#!INCLUDE .\Make_all.mak
+
+.SUFFIXES :
+
+!IFDEF PROGRAMW6432
+ProgFiles=%%PROGRAMFILES(x86)%%
+!ELSE
+ProgFiles=$(PROGRAMFILES)
+!ENDIF
+
+!IFDEF VIMSRC
+MKNSISFLAGS = /D"VIMSRC=$(VIMSRC)"
+!ENDIF
+
+!IFDEF VIMRT
+MKNSISFLAGS = $(MKNSISFLAGS) /D"VIMRT=$(VIMRT)"
+!ENDIF
+
+!IFDEF VIMTOOLS
+MKNSISFLAGS = $(MKNSISFLAGS) /D"VIMTOOLS=$(VIMTOOLS)"
+!ENDIF
+
+!IFDEF GETTEXT
+MKNSISFLAGS = $(MKNSISFLAGS) /D"GETTEXT=$(GETTEXT)"
+!ENDIF
+
+!IFDEF HAVE_UPX
+MKNSISFLAGS = $(MKNSISFLAGS) /DHAVE_UPX=$(HAVE_UPX)
+!ENDIF
+
+!IFDEF HAVE_NLS
+MKNSISFLAGS = $(MKNSISFLAGS) /DHAVE_NLS=$(HAVE_NLS)
+!ENDIF
+
+!IFDEF HAVE_MULTI_LANG
+MKNSISFLAGS = $(MKNSISFLAGS) /DHAVE_MULTI_LANG=$(HAVE_MULTI_LANG)
+!ENDIF
+
+!IFDEF WIN64
+MKNSISFLAGS = $(MKNSISFLAGS) /DWIN64=$(WIN64)
+!ENDIF
+
+!IFDEF INCLUDE_LIBGCC
+MKNSISFLAGS = $(MKNSISFLAGS) /DINCLUDE_LIBGCC=$(INCLUDE_LIBGCC)
+!ENDIF
+
+!IFDEF X
+XX = /X"$(X:;=" /X")"
+!ENDIF
+
+# If necessary, correct the full path of the NSIS compiler in the next line.
+# Please do not enclose the path in quotation marks.
+MKNSIS = $(ProgFiles)\NSIS
+
+PS = powershell.exe
+RM = del /f /q
+RD = rmdir /s /q
+
+MKNSISFLAGS = /INPUTCHARSET UTF8 $(MKNSISFLAGS)
+PSFLAGS = -NoLogo -NoProfile -Command
+
+# Read MAJOR and MINOR from version.h.
+!IF ![for /F "tokens=2,3" %G in ( \
+	'findstr /rc:"VIM_VERSION_MINOR[	^]*[0-9^]" \
+	/rc:"VIM_VERSION_MAJOR[	^]*[0-9^]" ..\src\version.h') do \
+	@if "VIM_VERSION_MAJOR"=="%G" (echo MAJOR=%H>>_ver.tmp) \
+	else echo MINOR=%H>>_ver.tmp]
+! INCLUDE .\_ver.tmp
+! IF [$(RM) .\_ver.tmp]
+! ENDIF
+!ENDIF
+
+# Read PATCHLEVEL from version.c
+!IF ![for /F %G in ( \
+	'findstr /nblc:"static int included_patches[^]" ..\src\version.c \
+	^| (set /p "_t=" ^& set /a _t+=2 ^)') do \
+	@cmd /q /c "for /F "skip=%G delims=, " %H in (..\src\version.c) do \
+			(echo PATCH=%H>_patchlvl.tmp & exit /b)"]
+! INCLUDE .\_patchlvl.tmp
+! IF [$(RM) .\_patchlvl.tmp]
+! ENDIF
+!ENDIF
+!IF $(PATCH) < 10
+PATCH = 000$(PATCH)
+!ELSEIF $(PATCH) < 100
+PATCH = 00$(PATCH)
+!ELSEIF $(PATCH) < 1000
+PATCH = 0$(PATCH)
+!ENDIF
+
+
+all : makeinst
+
+makeinst : prepare
+	^"$(MKNSIS)\makensis.exe" $(MKNSISFLAGS) gvim.nsi $(XX)
+
+prepare : unzipicons gvim_version.nsh license rename
+
+unzipicons : icons.zip
+	@ if exist %|fF\nul $(RD) %|fF
+	@ $(PS) $(PSFLAGS) \
+		Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; \
+		[System.IO.Compression.ZipFile]::ExtractToDirectory(\"$**\", \".\")
+
+gvim_version.nsh : Make_mvc.mak
+	@ 1> $@ echo:^# Generated from Makefile: define the version numbers
+	@ 1>> $@ echo:^!ifndef __GVIM_VER__NSH__
+	@ 1>> $@ echo:^!define __GVIM_VER__NSH__
+	@ 1>> $@ echo:^!define VER_MAJOR $(MAJOR)
+	@ 1>> $@ echo:^!define VER_MINOR $(MINOR)
+	@ 1>> $@ echo:^!define PATCHLEVEL $(PATCH)
+	@ 1>> $@ echo:^!endif
+
+license : ..\lang\LICENSE.*.txt ..\LICENSE
+	!@ $(PS) $(PSFLAGS) \
+		Get-Content -Path '$**' -Encoding UTF8 ^| \
+		Set-Content -Path '..\lang\$(**B).nsis.txt' -Enc Unicode -Force
+
+rename :
+	@ ..\tools\rename.bat "$(SRC)" "$(DST)" 1> nul
+
+clean :
+	@ if exist .\gvim_version.nsh $(RM) .\gvim_version.nsh
+	@ if exist ..\lang\LICENSE*.nsis.txt $(RM) ..\lang\LICENSE*.nsis.txt
+	@ if exist .\icons\nul $(RD) .\icons
+	@ if exist .\gvim??.exe $(RM) .\gvim??.exe
+
+# vim: set noet sw=8 ts=8 sts=0 wm=0 tw=0 ft=make:
diff --git a/nsis/Makefile b/nsis/Makefile
new file mode 100644
index 0000000..fdbc120
--- /dev/null
+++ b/nsis/Makefile
@@ -0,0 +1,95 @@
+#
+# Makefile for UNIX-like for create self-installing exe of Vim.
+# 15/12/2024, Restorer restorer@mail2k.ru
+#
+
+
+.SUFFIXES:
+.PHONY: all makeinst prepare rename clean 
+
+ifdef VIMSRC
+MKNSISFLAGS := -D"VIMSRC=$(VIMSRC)"
+endif
+
+ifdef VIMRT
+MKNSISFLAGS := $(MKNSISFLAGS) -D"VIMRT=$(VIMRT)"
+endif
+
+ifdef VIMTOOLS
+MKNSISFLAGS := $(MKNSISFLAGS) -D"VIMTOOLS=$(VIMTOOLS)"
+endif
+
+ifdef GETTEXT
+MKNSISFLAGS := $(MKNSISFLAGS) -D"GETTEXT=$(GETTEXT)"
+endif
+
+ifdef HAVE_UPX
+MKNSISFLAGS := $(MKNSISFLAGS) -DHAVE_UPX=$(HAVE_UPX)
+endif
+
+ifdef HAVE_NLS
+MKNSISFLAGS := $(MKNSISFLAGS) -DHAVE_NLS=$(HAVE_NLS)
+endif
+
+ifdef HAVE_MULTI_LANG
+MKNSISFLAGS := $(MKNSISFLAGS) -DHAVE_MULTI_LANG=$(HAVE_MULTI_LANG)
+endif
+
+ifdef WIN64
+MKNSISFLAGS := $(MKNSISFLAGS) -DWIN64=$(WIN64)
+endif
+
+ifdef INCLUDE_LIBGCC
+MKNSISFLAGS := $(MKNSISFLAGS) -DINCLUDE_LIBGCC=$(INCLUDE_LIBGCC)
+endif
+
+ifdef X
+XX := -X"$(X:;=" -X")"
+endif
+
+MAJOR != grep -E 'VIM_VERSION_MAJOR\s{2,}' ../src/version.h | \
+	awk '{ printf "%d",$$3 }'
+MINOR != grep -E 'VIM_VERSION_MINOR\s{2,}' ../src/version.h | \
+	awk '{ printf "%d",$$3 }'
+PATCH != awk '/number below this line/,/,/' ../src/version.c | \
+	awk 'NR == 3 { printf "%04d",$$1 }' | sed -e 's/[ ,]//g'
+
+MKNSISFLAGS := -INPUTCHARSET UTF8 $(MKNSISFLAGS)
+
+all: makeinst
+
+makeinst: prepare
+	makensis $(MKNSISFLAGS) gvim.nsi $(XX)
+
+prepare: unzipicons gvim_version.nsh license rename
+
+unzipicons: icons.zip
+	if test -d `basename $? .zip` ; then rm -rf `basename $? .zip` ; fi
+	unzip $?
+
+gvim_version.nsh: Makefile
+	echo "# Generated from Makefile: define the version numbers" > $@
+	echo "!ifndef __GVIM_VER__NSH__"  >> $@
+	echo "!define __GVIM_VER__NSH__"  >> $@
+	echo "!define VER_MAJOR $(MAJOR)" >> $@
+	echo "!define VER_MINOR $(MINOR)" >> $@
+	echo "!define PATCHLEVEL $(PATCH)" >> $@
+	echo "!endif" >> $@
+
+license: ../lang/LICENSE.*.txt ../LICENSE
+	for lic in $? ; do \
+		bn=`basename $$lic .txt` ; \
+		awk 'sub("$$", "\r")' < $$lic | \
+		iconv -f UTF-8 -t UTF-16 > ../lang/$$bn.nsis.txt ; \
+	done
+
+rename:
+	../tools/rename.bat "$(SRC)" "$(DST)"
+
+clean:
+	if test -f gvim_version.nsh ; then rm -f gvim_version.nsh ; fi
+	rm -f ../lang/LICENSE*.nsis.txt
+	if test -d icons ; then rm -rf icons ; fi
+	if test -f gvim??.exe ; then rm -f gvim??.exe ; fi
+
+# vim: set noet sw=8 ts=8 sts=0 wm=0 tw=0 ft=make:
diff --git a/nsis/README.txt b/nsis/README.txt
index 79c1952..4b4b7a0 100644
--- a/nsis/README.txt
+++ b/nsis/README.txt
@@ -3,22 +3,15 @@
 
 To build the installable .exe file:
 
-1.  Unpack three archives:
-	PC sources
-	PC runtime
-	PC language files
-    You can generate these from the Unix sources and runtime plus the extra
-    archive (see the Makefile in the top directory).
+Preparatory stage
 
-2.  Go to the src directory and build:
-	gvim.exe (the OLE version),
-	vimrun.exe,
-	install.exe,
-	uninstall.exe,
-	tee/tee.exe,
-	xxd/xxd.exe
+1.  Clone using the git tool the Vim repository or download its zip file
+    available at:
+	https://github.com/vim/vim
 
-    Then execute tools/rename.bat to rename the executables.
+2.  Go to the "/src" directory and build the Vim editor, making sure to use the
+    following variable values: "GUI=yes"; "OLE=yes"; "VIMDLL=yes". See
+    INSTALLpc.txt and Make_mvc.mak for details.
 
 3.  Go to the GvimExt directory and build gvimext.dll (or get it from a binary
     archive).  Both 64- and 32-bit versions are needed and should be placed
@@ -32,8 +25,8 @@
 	https://www.mediafire.com/file/9edk4g3xvfgzby0/diff4Vim.zip/file
     When will you have "diff.exe" put it in the "../.." directory (above the
     "vim91" directory, it's the same for all Vim versions).  However, you can
-    specify another directory by passing /DVIMTOOLS=<dir> option to the
-    "makensis.exe" program via the command line.
+    specify a different directory by specifying the appropriate makefile value.
+    How to do this is described below.
 
 5.  For the terminal window to work in Vim, the library winpty is required.
     You can get it at the following url:
@@ -41,8 +34,8 @@
     For the 32-bit version, rename "winpty.dll" from ia32/bin to "winpty32.dll",
     and for the 64-bit version — "winpty.dll" from x64/bin to "winpty64.dll".
     Put the renamed file and "winpty-agent.exe" in "../.." (above the "vim91"
-    directory).  However, you can specify another directory by passing
-    /DVIMTOOLS=<dir> option to the "makensis.exe" program via the command line.
+    directory).  However, you can specify a different directory by specifying
+    the appropriate makefile value. How to do this is described below. 
 
 6.  To use stronger encryption, add the Sodium library.  You can get it here:
 	https://github.com/jedisct1/libsodium/releases/download/1.0.19-RELEASE/libsodium-1.0.19-msvc.zip
@@ -52,12 +45,7 @@
     "../.." directory (above the "vim91" directory, where "diff.exe" and
     "winpty{32|64}.dll").
 
-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.  The created files
-    "uganda.nsis.???" will be automatically converted to DOS file format.
-
-8.  Get gettext and iconv DLLs from the following site:
+7.  Get gettext and iconv DLLs from the following site:
 	https://github.com/mlocati/gettext-iconv-windows/releases
     Both 64- and 32-bit versions are needed.
     Download the files gettextX.X.X.X-iconvX.XX-shared-{32,64}.zip, extract
@@ -74,35 +62,47 @@
 		libintl-8.dll
 		libiconv-2.dll
 
-    The default <GETTEXT directory> is "..", however, you can specify another
-    directory by passing /DGETTEXT=<dir> option to "makensis.exe" program via
-    the command line.
+    The default <GETTEXT directory> is "../..".  However, you can specify a
+    different directory by specifying the appropriate makefile value. How to do
+    this is described below. 
 
-
-Install NSIS if you didn't do that already.
-Download Unicode version the ShellExecAsUser plug-in for NSIS from:
+8.  Install NSIS if you didn't do that already.
+    Download Unicode version the ShellExecAsUser plug-in for NSIS from:
 	https://nsis.sourceforge.io/ShellExecAsUser_plug-in
-and put ShellExecAsUser.dll to path\to\NSIS\Plugins\x86-unicode
+    and put "ShellExecAsUser.dll" to path\to\NSIS\Plugins\x86-unicode
 
+Installer assembly stage
 
-Unpack the images:
-	cd nsis
-	unzip icons.zip or 7z x icons.zip (on Unix-like or MS Windows)
-	WinRar.exe x icons.zip (on MS Windows)
+    On MS Windows, open the Developer Command Prompt for VS and go to the
+    "/nsis" directory and type the command
+	    nmake.exe -lf Make_mvc.mak [variables] all
 
-Then build gvim.exe:
-	cd nsis
-	makensis.exe [options] gvim.nsi
+    After the installer is created and you copy it to the desired location, run
+    the following command in the "/nsis" directory
+	    nmake.exe -lf Make_mvc.mak clean
+    
+    On UNIX-like systems, go to the "/nsis" directory and type the command
+	    make -f Makefile [variables] all
 
-Options (not mandatory):
-    /DVIMSRC=<dir>	— directory where location of gvim_ole.exe, vimw32.exe,
+    After the installer is created and you copy it to the desired location, run
+    the following command in the "/nsis" directory
+	    make -f Makefile clean
+
+Variables and their values available for building the installer (not mandatory):
+
+    "VIMSRC=<dir>"	— directory where location of gvim_ole.exe, vimw32.exe,
 			    GvimExt/*, etc.
-    /DVIMRT=<dir>	— directory where location of runtime files
-    /DVIMTOOLS=<dir>    — directory where location of extra tools: diff.exe,
-			    winpty{32|64}.dll, winpty-agent.exe, libsodium.dll
-    /DGETTEXT=<dir>     — directory where location of gettext libraries
-    /DHAVE_UPX=1	— additional compression of the installer.  UPX program
+    "VIMRT=<dir>"	— directory where location of runtime files.
+    "VIMTOOLS=<dir>"    — directory where location of extra tools: diff.exe,
+			    winpty{32|64}.dll, winpty-agent.exe, libsodium.dll.
+    "GETTEXT=<dir>"     — directory where location of gettext libraries.
+    "HAVE_UPX=1"	— additional compression of the installer.  UPX program
 			    must be installed.
-    /DHAVE_NLS=0	— do not add native language support
-    /DHAVE_MULTI_LANG=0 — to create an English-only the installer
-    /DWIN64=1		— to create a 64-bit the installer
+    "HAVE_NLS=0"	— do not add native language support.
+    "HAVE_MULTI_LANG=0" — to create an English-only the installer.
+    "WIN64=1"		— to create a 64-bit the installer.
+    "X=<scriptcmd>"	— executes scriptcmd in script.  If multiple scriptcmd
+			    are specified, they are separated by a semicolon.
+			    Example "X=OutFile MyVim.exe;XPMode on"
+    "MKNSIS=<dir>"	— the directory where the "makensis.exe" program is
+			    located.
diff --git a/nsis/gvim.nsi b/nsis/gvim.nsi
index 3ea1d15..878867f 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 20
+# Last Change:	2025 Jan 05
 
 Unicode true
 
@@ -14,19 +14,19 @@
 
 # Location of runtime files
 !ifndef VIMRT
-  !define VIMRT ".."
+  !define VIMRT "..\runtime"
 !endif
 
 # Location of extra tools: diff.exe, winpty{32|64}.dll, winpty-agent.exe, etc.
 !ifndef VIMTOOLS
-  !define VIMTOOLS ..\..
+  !define VIMTOOLS "..\.."
 !endif
 
 # Location of gettext.
 # It must contain two directories: gettext32 and gettext64.
 # See README.txt for detail.
 !ifndef GETTEXT
-  !define GETTEXT ${VIMRT}
+  !define GETTEXT ${VIMTOOLS}
 !endif
 
 # If you have UPX, use the switch /DHAVE_UPX=1 on the command line makensis.exe.
@@ -74,6 +74,8 @@
 !include "nsDialogs.nsh"
 !include "Sections.nsh"
 !include "x64.nsh"
+!include "StrFunc.nsh"
+${StrRep}
 
 # See https://nsis.sourceforge.io/LogicLib
 ;FileExists is already part of LogicLib, but returns true for directories
@@ -246,6 +248,9 @@
 Var vim_compat_stat
 Var vim_keymap_stat
 Var vim_mouse_stat
+!if ${HAVE_NLS}
+Var lng_usr
+!endif
 
 
 # Reserve files
@@ -423,6 +428,7 @@
 	File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
 	File ..\vimtutor.bat
 	File ..\README.txt
+	File /oname=LICENSE.txt ..\LICENSE
 	File ..\uninstall.txt
 	File ${VIMRT}\*.vim
 
@@ -621,110 +627,23 @@
 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}
+	SetOutPath $INSTDIR
+!if /FileExists "..\lang\README.*.txt"
+	File ..\lang\README.*.txt
+	CopyFiles /SILENT /FILESONLY $INSTDIR\README.$lng_usr.txt \
+	       	$INSTDIR\vim${VER_MAJOR}${VER_MINOR}\README.$lng_usr.txt
+	Delete $INSTDIR\README.*.txt
 !endif
-!if /FileExists ..\README.nlx.txt
-    ${If} $Language = ${LANG_DUTCH}
-	File ..\README.nlx.txt
-    ${EndIf}
+!if /FileExists "..\lang\LICENSE.??.txt"
+	File ..\lang\LICENSE.??.txt
+!if /FileExists "..\lang\LICENSE.??_??.txt"
+	File ..\lang\LICENSE.??_??.txt
 !endif
-!if /FileExists ..\README.dex.txt
-    ${If} $Language = ${LANG_GERMAN}
-	File ..\README.dex.txt
-    ${EndIf}
+	CopyFiles /SILENT /FILESONLY $INSTDIR\LICENSE.$lng_usr.txt \
+	       	$INSTDIR\vim${VER_MAJOR}${VER_MINOR}\LICENSE.$lng_usr.txt
+	Delete $INSTDIR\LICENSE.*.txt
 !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
@@ -883,6 +802,20 @@
   !insertmacro MUI_LANGDLL_DISPLAY
 !endif
 
+!if ${HAVE_NLS}
+  ClearErrors
+  System::Call 'kernel32::GetUserDefaultLocaleName(t.r19, *i${NSIS_MAX_STRLEN})'
+  StrCmp $R9 "zh-cn" coincide 0
+  StrCmp $R9 "zh-tw" 0 part
+  coincide:
+  System::Call 'User32::CharLower(t r19 r19)*i${NSIS_MAX_STRLEN}'
+  ${StrRep} $lng_usr "$R9" "-" "_"
+  Goto done
+  part:
+  StrCpy $lng_usr $R9 2
+  done:
+!endif
+
   ${If} $INSTDIR == ${DEFAULT_INSTDIR}
     # Check $VIM
     ReadEnvStr $3 "VIM"
diff --git a/nsis/gvim_version.nsh b/nsis/gvim_version.nsh
index aee434b..c59366a 100644
--- a/nsis/gvim_version.nsh
+++ b/nsis/gvim_version.nsh
@@ -3,4 +3,5 @@
 !define __GVIM_VER__NSH__
 !define VER_MAJOR 9
 !define VER_MINOR 1
+!define PATCHLEVEL 0
 !endif
diff --git a/nsis/lang/README.txt b/nsis/lang/README.txt
index 68ff112..07899cb 100644
--- a/nsis/lang/README.txt
+++ b/nsis/lang/README.txt
@@ -18,17 +18,17 @@
  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"
+If you do not yet have a translated "LICENSE" file and/or a main "README.txt"
 file, set the following values:
 
 for the license file
-LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.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.
-
+Translation files should be located in the "lang" subdirectory of the root
+directory. The name of the files is as follows: "README.xx.txt", where xx is the
+language code according to ISO639.
diff --git a/nsis/lang/danish.nsi b/nsis/lang/danish.nsi
index ceb18be..c400031 100644
--- a/nsis/lang/danish.nsi
+++ b/nsis/lang/danish.nsi
@@ -19,15 +19,15 @@
 # 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"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_DANISH} "..\lang\LICENSE.da.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_DANISH} "README.da.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/dutch.nsi b/nsis/lang/dutch.nsi
index 49b1ed0..5a2ba14 100644
--- a/nsis/lang/dutch.nsi
+++ b/nsis/lang/dutch.nsi
@@ -21,15 +21,15 @@
 # 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"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_DUTCH} "..\lang\LICENSE.nl.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_DUTCH} "README.nl.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/english.nsi b/nsis/lang/english.nsi
index 6f69f58..d80f6f3 100644
--- a/nsis/lang/english.nsi
+++ b/nsis/lang/english.nsi
@@ -21,7 +21,7 @@
 # License file for the license page                                       {{{1
 ##############################################################################
 
-LicenseLangString page_lic_file ${LANG_ENGLISH} "${VIMRT}\doc\uganda.nsis.txt"
+LicenseLangString page_lic_file ${LANG_ENGLISH} "..\lang\LICENSE.nsis.txt"
 
 ##############################################################################
 # README.txt file, which is opened after installation                     {{{1
diff --git a/nsis/lang/german.nsi b/nsis/lang/german.nsi
index 21cf80e..59d65a3 100644
--- a/nsis/lang/german.nsi
+++ b/nsis/lang/german.nsi
@@ -21,15 +21,15 @@
 # Translated license file for the license page                            {{{1
 ##############################################################################
 
-LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
-#LicenseLangString page_lic_file ${LANG_GERMAN} "${VIMRT}\doc\uganda.nsis.dex"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_GERMAN} "..\lang\LICENSE.de.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_GERMAN} "README.de.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/greek.nsi b/nsis/lang/greek.nsi
index b92d3f3..d746cb3 100644
--- a/nsis/lang/greek.nsi
+++ b/nsis/lang/greek.nsi
@@ -21,15 +21,15 @@
 # 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"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_GREEK} "..\lang\LICENSE.el.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_GREEK} "README.el.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/italian.nsi b/nsis/lang/italian.nsi
index 5f32680..629d476 100644
--- a/nsis/lang/italian.nsi
+++ b/nsis/lang/italian.nsi
@@ -21,15 +21,13 @@
 # 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"
+LicenseLangString page_lic_file ${LANG_ITALIAN} "..\lang\LICENSE.it.nsis.txt"
 
 ##############################################################################
 # 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"
+LangString vim_readme_file ${LANG_ITALIAN} "README.it.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/japanese.nsi b/nsis/lang/japanese.nsi
index d290355..c28529c 100644
--- a/nsis/lang/japanese.nsi
+++ b/nsis/lang/japanese.nsi
@@ -31,15 +31,15 @@
 # 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"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_JAPANESE} "..\lang\LICENSE.ja.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_JAPANESE} "README.ja.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/russian.nsi b/nsis/lang/russian.nsi
index 876bef2..bcb5467 100644
--- a/nsis/lang/russian.nsi
+++ b/nsis/lang/russian.nsi
@@ -21,13 +21,13 @@
 # Translated license file for the license page                            {{{1
 ##############################################################################
 
-LicenseLangString page_lic_file ${LANG_RUSSIAN} "${VIMRT}\doc\uganda.nsis.rux"
+LicenseLangString page_lic_file ${LANG_RUSSIAN} "..\lang\LICENSE.ru.nsis.txt"
 
 ##############################################################################
 # Translated README.txt file, which is opened after installation          {{{1
 ##############################################################################
 
-LangString vim_readme_file ${LANG_RUSSIAN} "README.rux.txt"
+LangString vim_readme_file ${LANG_RUSSIAN} "README.ru.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/serbian.nsi b/nsis/lang/serbian.nsi
index 122727d..9b829ef 100644
--- a/nsis/lang/serbian.nsi
+++ b/nsis/lang/serbian.nsi
@@ -21,15 +21,15 @@
 # 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"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_SERBIAN} "..\lang\LICENSE.sr.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_SERBIAN} "README.sr.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/simpchinese.nsi b/nsis/lang/simpchinese.nsi
index 8d2d073..0c9290e 100644
--- a/nsis/lang/simpchinese.nsi
+++ b/nsis/lang/simpchinese.nsi
@@ -22,16 +22,16 @@
 # Translated license file for the license page                            {{{1
 ##############################################################################
 
-LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
 #LicenseLangString page_lic_file ${LANG_SIMPCHINESE} \
-#        "${VIMRT}\doc\uganda.nsis.cnx"
+#        "..\lang\LICENSE.zh_cn.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_SIMPCHINESE} "README.zh_cn.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/tradchinese.nsi b/nsis/lang/tradchinese.nsi
index 66bb1b8..5d9a5d3 100644
--- a/nsis/lang/tradchinese.nsi
+++ b/nsis/lang/tradchinese.nsi
@@ -22,16 +22,16 @@
 # Translated license file for the license page                            {{{1
 ##############################################################################
 
-LicenseLangString page_lic_file 0 "${VIMRT}\doc\uganda.nsis.txt"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
 #LicenseLangString page_lic_file ${LANG_TRADCHINESE} \
-#        "${VIMRT}\doc\uganda.nsis.twx"
+#        "..\lang\LICENSE.zh_tw.nsis.txt"
 
 ##############################################################################
 # 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"
+#LangString vim_readme_file ${LANG_TRADCHINESE} "README.zh_tw.txt"
 
 ##############################################################################
 # MUI Configuration Strings                                               {{{1
diff --git a/nsis/lang/turkish.nsi b/nsis/lang/turkish.nsi
index 429cbb3..3522faa 100644
--- a/nsis/lang/turkish.nsi
+++ b/nsis/lang/turkish.nsi
@@ -20,15 +20,15 @@
 # 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"
+LicenseLangString page_lic_file 0 "..\lang\LICENSE.nsis.txt"
+#LicenseLangString page_lic_file ${LANG_TURKISH} "..\lang\LICENSE.tr.nsis.txt"
 
 ##############################################################################
 # 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 vim_readme_file ${LANG_TURKISH} "README.tr.txt"
 
 ##############################################################################