Skip to content
⌘ NSIS Forum Archive

Multilingual installation: Version number in caption

6 posts

stopasking#

Multilingual installation: Version number in caption

Hello!

I want to add a version number to my installation caption, but leave the name without the version number in all other places.

makensis does it the following way:
Name "NSIS"
Caption "NSIS ${VERSION} Setup"
This works only for an English-only installation.

I tried to do the following:
!searchreplace "ASDF_${LANGLOAD}" "$(^SetupCaption)" "$(^Name)" "$(^Name) v${VERSION}"
LangString "^SetupCaption" "${LANG_${LANG_LOADING}}" "${ASDF_${LANGLOAD}}"
Where "${LANGLOAD}" is every loaded language. It does not work.

Any suggestions? Another option I see is editing .nlf files, but this is quite an ugly solution.
stopasking#
Well, I can do a LangString for every supported language, but I think the method sucks.
What if, e.g., a new version of NSIS is released with a better translation for some language?

I don't want to copy the strings from nsis .nlf files to my installation script, I just want to append a version number to ^Name in ^SetupCaption.
Afrow UK#
There is no way to do this. You have to either just put the version in Name or create your own LangString.

Stu
stopasking#
Can't you get the contents of "$(^SetupCaption)" somehow?
There's also this trick I saw (I think you are the author of it):


Which might get the job done, but is ugly as well.
Seems like the easiest way here is to modify the .nlf files.
Anders#
The easy solution is of course to put the version number in "Name", if you don't want to do that you can use this ugly workaround:

outfile test.exe
requestexecutionlevel user
Name "Test"
!define VERSION 1.2.3
!macro CreateSetupCaptionLangstring lang prefix suffix
!tempfile tnsi
!appendfile "${tnsi}" 'outfile "${tnsi}.exe"$\nrequestexecutionlevel user$\nLoadLanguageFile "${NSISDIR}\Contrib\Language files\${lang}.nlf"$\n'
!appendfile "${tnsi}" 'section$\nFileOpen $0 "${tnsi}.nsh" w$\n'
!appendfile "${tnsi}" 'FileWrite $0 `!define SetupCaption "$(^SetupCaption)"`$\nsectionend$\nName "xxx"$\n'
!system '"${NSISDIR}\makensis" "${tnsi}"' = 0
!delfile "${tnsi}"
!system '"${tnsi}.exe" /S' = 0
!delfile "${tnsi}.exe"
!include "${tnsi}.nsh"
!delfile "${tnsi}.nsh"
!undef tnsi
!searchreplace SetupCaption "${SetupCaption}" "xxx " "${prefix}"
!ifndef LANG_${lang}
    LoadLanguageFile "${NSISDIR}\Contrib\Language files\${lang}.nlf"
!endif
LangString "^SetupCaption" ${LANG_${lang}} "${SetupCaption}${suffix}"
!undef SetupCaption
!macroend
!macro LOAD_MUILANGUAGE_AND_SETUPCAPTION lang prefix suffix
!insertmacro MUI_LANGUAGE "${lang}"
!insertmacro CreateSetupCaptionLangstring "${lang}" "$(^Name) v${VERSION} " ""
!macroend
!include "MUI2.nsh"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro LOAD_MUILANGUAGE_AND_SETUPCAPTION "English" "$(^Name) v${VERSION} " ""
!insertmacro LOAD_MUILANGUAGE_AND_SETUPCAPTION "Swedish" "$(^Name) v${VERSION} " ""
!insertmacro LOAD_MUILANGUAGE_AND_SETUPCAPTION "Norwegian" "$(^Name) v${VERSION} " ""
!insertmacro MUI_RESERVEFILE_LANGDLL
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
section
sectionend