Multiple language support

Anonymous user
Multiple language support

Hope can support multiple languages

Posts: 1121
Joined: March 25, 2012 - 01:19
I'll ask the community to

I'll ask the community to help me in IDE translation, but only when the first 1.x version will be released.
Things are changing day by day, so a translation could become quickly unuseful now.

Stay tuned

Anonymous user
multiple languages in dialogs

I think the request is refering to support multiple languages in edited dialog texts, not in the designer UI...

Posts: 1121
Joined: March 25, 2012 - 01:19
Oops, I haven't thougth it

Oops, I haven't thougth it ;)

How should the language strings be generated into .nsdinc file?
Could you send me a sample script?

Anonymous user
multiple languages in dialogs experience

I'm just beginning to play with NSIS installer. I've currently supported the multilanguage feature this way:

!define MUI_LANGDLL_ALLLANGUAGES
 
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Spanish"
 
!insertmacro MUI_RESERVEFILE_LANGDLL
 
!include "resources\english.lang"
!include "resources\spanish.lang"

where the resource files contain string defintions for each supported language, like this

; resources\english.lang
LangString TextDirectoryTitle ${LANG_ENGLISH} "Installation folder"
LangString TextDirectorySubtitle ${LANG_ENGLISH} "Select the installation folder."
 
; resources\spanish.lang
LangString TextDirectoryTitle ${LANG_SPANISH} "Directorio de instalación"
LangString TextDirectorySubtitle ${LANG_SPANISH} "Seleccione el directorio de instalación."

Then, when I need to use the strings in the pages, I do this:

!define MUI_PAGE_HEADER_TEXT "$(TextDirectoryTitle)"
!define MUI_PAGE_HEADER_SUBTEXT "$(TextDirectorySubtitle)"
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY

But now I need to define a custom dialog with my own settings. First I've tried to define the dialog in a .ini file with HM NIS Editor. The .ini file looks like this:

[Settings]
NumFields=9
Title=Application Settings
 
...	
[Field 9]
Type=Checkbox
Text=Run Application on Windows Startup
State=0
Left=20
Right=180
Top=20
Bottom=31

HM NIS Editor hasn't multilanguage support, but this issue can be solved when using the dialog, re-writing the Text field:

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "appSettings.ini"
;...
!insertmacro MUI_INSTALLOPTIONS_WRITE "appSettings.ini" "Field 9" "Text" "$(TextRunOnStartup)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "appSettings.ini"

As the InstallOptions plug-in with .ini files is deprecated, now the way to make custom dialogs is nsDialogs plug-in. And I've found NSIS Dialog Designer. It's great and easy to use, but doesn't support multilanguage. The only way I see now to redefine texts in another language is to edit manually the .nsdinc file and replace the texts by variable names:

; === CheckBox7 (type: Checkbox) ===
${NSD_CreateCheckbox} 18 31 244 25 "Run Application on Windows Startup"
Pop $hCtl_UpdaterAppSettings_CheckBox7

replace it with:

; === CheckBox7 (type: Checkbox) ===
${NSD_CreateCheckbox} 18 31 244 25 "$(TextRunOnStartup)"
Pop $hCtl_UpdaterAppSettings_CheckBox7

This is quite heavy work! It would be great if, at least, all the Text strings where stored in a separated resource file. So, I'll only have to translate the file and include it, without having to modify the script code itself.

Anonymous user
multiple languages in dialogs (workaround)

Referring to my previous post with my problems with custom multilanguage forms, I've found a little workaround that works for me with my current NSIS scripts. Let's remember. I had implemented the multilanguage feature this way:

!define MUI_LANGDLL_ALLLANGUAGES
 
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Spanish"
 
!insertmacro MUI_RESERVEFILE_LANGDLL
 
!include "resources\english.lang"
!include "resources\spanish.lang"

where the resource files contained string definitions for each supported language, like this

; resources\english.lang
LangString TextDirectoryTitle ${LANG_ENGLISH} "Installation folder"
LangString TextDirectorySubtitle ${LANG_ENGLISH} "Select the installation folder."
 
; resources\spanish.lang
LangString TextDirectoryTitle ${LANG_SPANISH} "Directorio de instalacion"
LangString TextDirectorySubtitle ${LANG_SPANISH} "Seleccione el directorio de instalacion."

Now, I edit my dialog with NSIS Dialog Designer, putting variable references instead of text in the Text field of the control properties. That is, I put "$(TextDirectoryTitle)" instead of "Installation folder". And it works.

Posts: 1121
Joined: March 25, 2012 - 01:19
Your workaround is the best way to do it

@loverkraft
Reading official documentation here: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.15
it seems that your "workaround" is the best way to create a multilanguage setup, and it's compatible with NSISDialogDesigner too.

So I think NSISDialogDesigner should not be changed at all...

warning

Warning, JavaScript is disabled!

JavaScript is not available, maybe because you disabled it globally into your browser settings or you are using an addon like NoScript.

We do not have any dangerous JavaScript running here.
Please enable JavaScript; if you're using NoScript this image will help you adding CoolSoft to your whitelist.

Thanks for your comprehension and enjoy CoolSoft.