Archive: Internationalization


Internationalization
hy.
I try the example in the help:

i put this in the begin of the file
LangString message ${LANG_ENGLISH} "English message"
LangString message ${LANG_FRENCH} "French message"
LangString message ${LANG_ITALIAN} "ITALIAN message"

and i set this in the define part:

!define MUI_WELCOMEPAGE_TITLE $(msgTitleWelcome)
!define MUI_WELCOMEPAGE_TEXT $(msgTextWelcome)
MessageBox MB_OK "A translated message: $(message)"

before the !insertmacro MUI_PAGE_WELCOME
but don't work


an alternative is define all' the text message in the top of the sript without the translation and insert all in the pages definition.
How do this?
thanks


Okay, so pay attention to that:

in the .onInit function:

!insertmacro MUI_LANGDLL_DISPLAY

to ask for the language at the begining of the installation.

Then do not used messages in the .onInit function since the language is still not taken into account. Wait for the second function...

in a customized OnGuiInit function,
do your message display via MessageBox.

It must work. And it will in all the later sections/functions..

In your example, in which function/section is located your MessageBox ?


Gal'


i insert
!insertmacro MUI_LANGDLL_DISPLAY
in the .oninit function, but dont show the language selection dialog.


Try to compile and run that:


!include "MUI.nsh"

Name "Modern UI Test"
OutFile test.exe
XPStyle on


!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Dutch"


LangString msg ${LANG_ENGLISH} "English msg"
LangString msg ${LANG_DUTCH} "Dutch msg"


function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
functionEnd

section "Silent" SILENT_SEC
MessageBox MB_OK "$(msg)" ; $() instead of ${}
sectionEnd




Gal'

PS: insert your MUI_LANGUAGES after the MUI_PAGES

Using
MessageBox MB_OK $(SEC0001_NAME)

I got always the same output, no matter what Language I've chosen. Now I know why - the language is not taken into account.

But where can I do things like that?
Error: Function named ".OnGuiInit" already exists. can I add there some lines? I want to do
'!insertmacro SelectSection SEC0001' / '!insertmacro UnSelectSection SEC0001' depening on the language chosen.


!define MUI_CUSTOMFUNCTION_GUIINIT myOnGUIInit

Stu


Now I can call my function. Fine. New Prolem

If I do

Function SELECT_LANGSECTIONS # selecting installer sections (languages)
${If} $(SEC0002_NAME) == "Français"
!insertmacro SelectSection SEC0002
!insertmacro SetSectionFlag SEC0002 2
${EndIf}}
FunctionEnd
, the installer has 100% CPU and have to be killed when reaching the Select Page.

Why is that? I use the following definition
    Section /o $(SEC0002_NAME) SEC0002
SetOutPath $INSTDIR\fr
SetOverwrite on
File /r ..\bin\Release\fr\*
File /r ..\bin\Release\help\fr\*
WriteRegStr HKLM "${REGKEY}\Components" French 1
SectionIn 3
SectionEnd

This seems to be a bug in NSIS, is there a workaround for now?


For the macro insertions, you need to pass ${SEC0002} not SEC0002.

Stu


I don't know what you are trying to do, but look at my example above. Why are you defining a select_langsection function ? why do you need it ? Normally you don't...

what do you want to do ? have a section only if the language is French (have a test encapsulating the section description) ? Or do you want to have the components page in the selected Language (automated with use of LangString) ?

Gal'


I've tried ${SEC0001} before but didn't worked (Variable/Constant undefined): I had to put my function after the sections were defined.

But the problem stays the same: 100% CPU using and the only option to kill the installer.

There is a program in english with different language packages for other languages and three InstTypes:

InstType $(inst_minimal)  #means installation without any additional language --> only english
InstType $(inst_standard) #means installation with the language chosen at installatin begining as additional packet
InstType $(inst_full) #means installation with all available language packets

This is what I want to do: Add the chosen language of the installer to the InstType $(inst_standard) and select the standard type, so that the user does not to have choose the language twice.

Is it possible to 'delete' the InstType $(inst_minimal) or $(inst_standard) if the user chooses english?

I use the following code (with InstTypes as shown before )
# Installer sections
Section $(SEC0000_NAME) SEC0000
SetOutPath $INSTDIR
SetOverwrite on
File ..\bin\Release\license.rtf
SetOutPath $INSTDIR\en
File /r ..\bin\Release\help\en\*
WriteRegStr HKLM "${REGKEY}\Components" MainProg 1
SectionIn RO # This Section is allways checked and cannot be disabled
SectionEnd

SectionGroup /e $(SECGRP0000_NAME) SECGRP0000
# what languages belongs to standard type
# is choosen dynamically via SELECT_LANGSECTIONS
Section /o $(SEC0001_NAME) SEC0001
SetOutPath $INSTDIR\de
SetOverwrite on
File /r ..\bin\Release\de\*
File /r ..\bin\Release\help\de\*
File ..\bin\Release\lizenz.rtf
WriteRegStr HKLM "${REGKEY}\Components" German 1
SectionIn 3
SectionEnd

Section /o $(SEC0002_NAME) SEC0002
SetOutPath $INSTDIR\fr
SetOverwrite on
File /r ..\bin\Release\fr\*
File /r ..\bin\Release\help\fr\*
WriteRegStr HKLM "${REGKEY}\Components" French 1
SectionIn 3
SectionEnd
SectionGroupEnd

Function MyOnGuiInit
# selecting installer sections (languages)
${If} $(SEC0001_NAME) == "Deutsch"
!insertmacro SelectSection ${SEC0001}
!insertmacro SetSectionFlag ${SEC0001} 2
${Else}
${If} $(SEC0002_NAME) == "Français"
!insertmacro SelectSection ${SEC0002}
!insertmacro SetSectionFlag ${SEC0002} 2
${EndIf}
${EndIf}
FunctionEnd

LangString SEC0001_NAME ${LANG_ENGLISH} "German"
LangString SEC0002_NAME ${LANG_ENGLISH} "French"
LangString SEC0001_NAME ${LANG_GERMAN} "Deutsch"
LangString SEC0002_NAME ${LANG_FRENCH} "Français"


There is no CPU problem when using
!insertmacro SetSectionFlag ${SEC0001} ${SF_2}
but I receive
unknown variable/constant "{SF_2}" detected, ignoring (macro:SetSectionFlag:6)
and because of this - no definition of InstType $(inst_standard).

If it says it is undefined then that means your code needs to go below the sections in your script.

Stu


As I said before:

Originally posted by only_johhny
I've tried ${SEC0001} before but didn't worked (Variable/Constant undefined): I had to put my function after the sections were defined.
The problem is: what should I do because of this "have to kill installer"-thing

What is ${SF_2}? The constants that you can use are in Sections.nsh. A value of 2 is ${SF_SECGRP} or in other words, setting it means you are turning your section into a group marker.

Stu


Oops... How can I do what I want? Any suggestions?