Old 8th March 2007, 11:33   #1
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
PreSelect a component by language

Hi together.

I've got a problem. I've have templates to install. Only one template should be selectable at once (problem solved). The other thing is that the installer should check which Language the system has and preselect the correct template for the user. I've startet with the following code:

code:

var PreSelect

[... in the .oninit function ...]
StrCmp $LANGUAGE ${LANG_FRENCH} 0 +3
StrCpy $PreSelLang ${template_french}
goto PreSelectEnd

StrCmp $LANGUAGE ${LANG_GERMAN} 0 +3
StrCpy $PreSelLang ${template_german}
goto PreSelectEnd

StrCmp $LANGUAGE ${LANG_ITALIAN} 0 +3
StrCpy $PreSelLang ${template_italian}
goto PreSelectEnd

StrCmp $LANGUAGE ${LANG_SPANISH} 0 PreSelectEnd
StrCpy $PreSelLang ${template_spanish}
goto PreSelectEnd

StrCpy $PreSelLang ${template_english}
goto PreSelectEnd

PreSelectEnd:

[... the sections ...]
SectionGroup "Template language" templates
Section /o "English" templates_english
[stuff]
SectionEnd

Section /o "German" templates_german
[stuff]
SectionEnd

Section /o "French" templates_french
[stuff]
SectionEnd

Section /o "Italian" templates_italian
[stuff]
SectionEnd

Section /o "Spanish" templates_spanish
[stuff]
SectionEnd
SectionGroupEnd


.... and ...

Function .onSelChange
# EN, DE, IT, ES, FR
!insertmacro StartRadioButtons $PreSelLang
!insertmacro RadioButton ${templates_english}
!insertmacro RadioButton ${templates_french}
!insertmacro RadioButton ${templates_german}
!insertmacro RadioButton ${templates_italian}
!insertmacro RadioButton ${templates_spanish}
!insertmacro EndRadioButtons
FunctionEnd




What am I doing wrong? THe Buttons are RadioButtons but whatever language I have nothing is preselected. Any ideas? Thanks.
dbach is offline   Reply With Quote
Old 8th March 2007, 11:59   #2
onad
Senior Member
 
onad's Avatar
 
Join Date: Dec 2004
Location: Turkey
Posts: 447
TIP:

Note that OS GUI language has nothing to do with the Targetcountry of your installer, make sure you do not confuse Language with Country, e.g. a person could have an Spanish OS GUI langiage but still have his country set to United States, since he/she lives there but prefers Spanish as OS language.

"Just do it"
onad is offline   Reply With Quote
Old 8th March 2007, 12:06   #3
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
Hi onad,

thanks for the tip. I almost forgot to post the following lines which are also in my Installer:
code:
System::Call "kernel32::GetUserDefaultLangID()i .r0"
StrCpy $LANGUAGE $0


So the Regional Settings should be used.
dbach is offline   Reply With Quote
Old 8th March 2007, 16:16   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
code:
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\French.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\German.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Italian.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Spanish.nlf"

!include "LogicLib.nsh"
!include "Sections.nsh"

outfile 'test.exe'

Var PreSelLang

Page Components
Page InstFiles

SectionGroup /e "Template language" templates
Section /o "English" templates_english
; [stuff]
SectionEnd

Section /o "German" templates_german
; [stuff]
SectionEnd

Section /o "French" templates_french
; [stuff]
SectionEnd

Section /o "Italian" templates_italian
; [stuff]
SectionEnd

Section /o "Spanish" templates_spanish
; [stuff]
SectionEnd
SectionGroupEnd

Function .onInit
System::Call "kernel32::GetUserDefaultLangID()i .r0"
StrCpy $LANGUAGE $0

${if} $LANGUAGE == ${LANG_FRENCH}
!insertmacro SelectSection ${templates_french}
StrCpy $PreSelLang ${templates_french}

${elseif} $LANGUAGE == ${LANG_GERMAN}
!insertmacro SelectSection ${templates_german}
StrCpy $PreSelLang ${templates_german}

${elseif} $LANGUAGE == ${LANG_ITALIAN}
!insertmacro SelectSection ${templates_italian}
StrCpy $PreSelLang ${templates_italian}

${elseif} $LANGUAGE == ${LANG_SPANISH}
!insertmacro SelectSection ${templates_spanish}
StrCpy $PreSelLang ${templates_spanish}

${else}
!insertmacro SelectSection ${templates_english}
StrCpy $PreSelLang ${templates_english}
${endif}

MessageBox MB_OK "$$0 = $0 - $$LANGUAGE = $LANGUAGE - $$PreSelLang = $PreSelLang"
FunctionEnd

Function .onSelChange
# EN, DE, IT, ES, FR
!insertmacro StartRadioButtons $PreSelLang
!insertmacro RadioButton ${templates_english}
!insertmacro RadioButton ${templates_french}
!insertmacro RadioButton ${templates_german}
!insertmacro RadioButton ${templates_italian}
!insertmacro RadioButton ${templates_spanish}
!insertmacro EndRadioButtons
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 9th March 2007, 07:58   #5
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
Thanks RedWine - this works. Now I have to solve another problem. My onInit function is before my sections. When I move my oninit function after the section the installers starts again and again and again (3 times before the first dialog appears). I have to investigate to solve this problem. Thanks again
dbach 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