Old 22nd July 2019, 14:11   #1
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
Localization of Section name/description and shortcuts

Hello.

I'm looking for a sample of script that help me to modify a current .NSI script based on single language to multi-language regarding

- Section name (multi-language)
- Section description (multi-language)
- Icon link description (multi-language).

I search on different forum but I didn't find it.

This the current file that I developped (but didn't work)

https://mega.nz/#!XdJE3ShB!xs-AAfoJe...m_24-M_Rddnqaw

It's the installer script for QEMU

Thanks in advance.
bovirus is offline   Reply With Quote
Old 22nd July 2019, 15:10   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
MUI already has a section description example.

What is "icon link description"? A .lnk shortcut comment?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd July 2019, 15:21   #3
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
Hello.

Thanks for quickly reply.

I tried to make it myself but probably there some syntax errors in my script.
Could you please check it and provide me an idea where could be the error?

When you create a program group could be a good idea to have the program description in program group localized.
Ex. If you select English as language for the installer the program description in program group could be

"Uninstall xxx" (xx program name)

and if you select Italian could be

"Disinstalla xxx".

Thanks.
bovirus is offline   Reply With Quote
Old 22nd July 2019, 15:53   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
Quote:
Originally Posted by bovirus View Post

When you create a program group could be a good idea to have the program description in program group localized.
Ex. If you select English as language for the installer the program description in program group could be

"Uninstall xxx" (xx program name)

and if you select Italian could be

"Disinstalla xxx".
Just to clarify, you are talking about start menu shortcuts here?

The Windows guidelines say that you should not create links to uninstallers and helpfiles, only your main application.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd July 2019, 15:28   #5
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
@Anders

Of course I red many web pages and tried to interpreter the explanation but surely I made something wrong.
bovirus is offline   Reply With Quote
Old 22nd July 2019, 15:58   #6
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
Yes.
Start menu shorcuts in program group.
Ok for Uninstall/Help.
I think for exmaple to the shortcuts that open program web site.

"Open program web site" (English)
"Apri sito web programma" (Italian)

But my main scope is to localize section name and description (tip) showed during installation".
bovirus is offline   Reply With Quote
Old 22nd July 2019, 17:52   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
PHP Code:
!include MUI2.nsh
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
!insertmacro MUI_LANGUAGE Swedish

Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Section 
"$(Sec1Name)" Section1
SectionEnd

Section 
"$(Sec2Name)" Section2
SectionEnd

LangString Sec1Name 
${LANG_ENGLISH"Section 1"
LangString Sec2Name ${LANG_ENGLISH"Section 2"
LangString DESC_Section1 ${LANG_ENGLISH"Description of section 1."
LangString DESC_Section2 ${LANG_ENGLISH"Description of section 2."
LangString Sec1Name ${LANG_SWEDISH"Chef"
LangString Sec2Name ${LANG_SWEDISH"Meatball"
LangString DESC_Section1 ${LANG_SWEDISH"Bork 1."
LangString DESC_Section2 ${LANG_SWEDISH"Bork bork 2."

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
    !
insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!
insertmacro MUI_FUNCTION_DESCRIPTION_END 
The shortcut guideline applies to internet shortcuts as well.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd July 2019, 18:24   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
If you want your main application shortcut to be based on a language string things get tricky.

* Option A, delete all possible names:

PHP Code:
!define LNKNAME_ENGLISH "MyApp"
!define LNKNAME_SWEDISH "BorkApp"
LangString LnkName ${LANG_ENGLISH"${LNKNAME_ENGLISH}"
LangString LnkName ${LANG_SWEDISH"${LNKNAME_SWEDISH}"

Section
CreateShortcut 
"$SMPrograms\$(LnkName).lnk" "$InstDir\MyApp.exe"
SectionEnd

Section Uninstall
Delete 
"$SMPrograms\${LNKNAME_ENGLISH}.lnk"
Delete "$SMPrograms\${LNKNAME_SWEDISH}.lnk"
SectionEnd 
* Option B, storage:

Store the shortcut name somewhere (.ini or registry) when installing and use that name when uninstalling.

* Option C, shell display names (Vista+):

PHP Code:
LangString LnkDisplayName ...
Section
WriteIniStr 
"$SMPrograms\Desktop.ini" "LocalizedFileNames" "MyApp.lnk" "$(LnkDisplayName)"
SetFileAttributes "$SMPrograms\Desktop.ini" SYSTEM|HIDDEN|ARCHIVE
CreateShortcut 
"$SMPrograms\MyApp.lnk" "$InstDir\MyApp.exe"
SectionEnd

Section Uninstall
Delete 
"$SMPrograms\MyApp.lnk"
DeleteINIStr "$SMPrograms\Desktop.ini" "LocalizedFileNames" "MyApp.lnk"
SectionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 23rd July 2019, 10:06   #9
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
@Anders

Thanks a lot for your professional explanation

Can I use also a syntax like

LangString LnkName ${LANG_ENGLISH} "MyApp"
LangString LnkName ${LANG_SWEDISH} "BorkApp"

Section
CreateShortcut "$SMPrograms\$(LnkName).lnk" "$InstDir\MyApp.exe"
SectionEnd

Section Uninstall
Delete "$SMPrograms\$(LnkName).lnk"
SectionEnd

Of course you version is more complete because delete all links in any languages.

In my example uninstall only a link in the same single language.
bovirus is offline   Reply With Quote
Old 23rd July 2019, 12:02   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
You can but you need to set the correct language in un.onInit. MUI might do it for you if you are using its registry defines and language macros.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 25th July 2019, 08:41   #11
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
@Anders

Thank a lot for your help.
I completed the script and now it works the mouldes name as multilanguage.

can I define the variable in a external file (one for each language)? Ex.

---- Mainscript

!include installer_english_strings.nsh
!include installer_swedish_strings.nsh

Section
CreateShortcut "$SMPrograms\$(LnkName).lnk" "$InstDir\MyApp.exe"
SectionEnd

Section Uninstall
Delete "$SMPrograms\${LNKNAME_ENGLISH}.lnk"
Delete "$SMPrograms\${LNKNAME_SWEDISH}.lnk"
SectionEnd

------------- File installer_english_strings.nsh
!define LNKNAME_ENGLISH "MyApp"
LangString LnkName ${LANG_ENGLISH} "${LNKNAME_ENGLISH}"

------------- File installer_swedish_strings.nsh
!define LNKNAME_SWEDISH "BorkApp"
LangString LnkName ${LANG_SWEDISH} "${LNKNAME_SWEDISH}"

Thanks.
bovirus is offline   Reply With Quote
Old 25th July 2019, 09:54   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
Yes you can do that as long as you put the !include at the correct location in your .NSI. !include is just a copy&paste of text.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th August 2019, 10:00   #13
bovirus
Junior Member
 
Join Date: Jul 2019
Posts: 8
Anders

Could be in the same way for Memento section like

${MementoSection} "NppExport" NppExport
Delete "$INSTDIR\plugins\NppExport.dll"
Delete "$INSTDIR\plugins\NppExport\NppExport.dll"
Delete "$PLUGIN_INST_PATH\NppExport\NppExport.dll"

SetOutPath "$PLUGIN_INST_PATH\NppExport"
!ifdef ARCH64
File "..\bin64\plugins\NppExport\NppExport.dll"
!else
File "..\bin\plugins\NppExport\NppExport.dll"
!endif
${MementoSectionEnd}

Thanks.
bovirus is offline   Reply With Quote
Old 6th August 2019, 00:51   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,172
Use a langstring like you do with a normal section.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump