Old 1st February 2007, 10:19   #1
Marcus1807
Junior Member
 
Join Date: Jan 2007
Posts: 8
language settings on custom page

Hi,

how can I change the language on a customPage?
I've coded the texts hard into the installer script.
But ho can I change the language with the language dialog?
Any ideas?

Thanks...
here is my code:

PHP Code:
Script generated by the HM NIS Edit Script Wizard.
!include 
WinMessages.nsh
!include LogicLib.nsh

MUI 1.67 compatible ------
!include 
"MUI.nsh"

Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

Welcome page
 
!insertmacro MUI_PAGE_WELCOME
;Custum Function
  
Page custom showCheckSummary leaveCheckSummary
License page
 
!define MUI_LICENSEPAGE_CHECKBOX
 
!insertmacro MUI_PAGE_LICENSE "Prototype.txt"
Directory page
 
!insertmacro MUI_PAGE_DIRECTORY
Instfiles page
 
!insertmacro MUI_PAGE_INSTFILES
Finish page
 
!insertmacro MUI_PAGE_FINISH
Uninstaller pages
 
!insertmacro MUI_UNPAGE_INSTFILES

Language files
 
!insertmacro MUI_LANGUAGE "English"
 
!insertmacro MUI_LANGUAGE "German"

MUI end ------

Name "${PRODUCT_NAME}"
OutFile "Setup_ADEPAut.exe"

;VAR INI_VALUE
VAR ERROR_MESSAGE


Function showCheckSummary
 
!insertmacro MUI_HEADER_TEXT "Environment errors" "The following environment checks failed."
 
 
;if no errors were found go to done else goto notEqual
 strcmp 
$"false" done notEqual
 notEqual
:
  ;
writeinistr "$PLUGINSDIR\checkSummary.ini" "FIELD 3" "State" "0"
  
!insertmacro MUI_INSTALLOPTIONS_WRITE "checkSummary.ini" "FIELD 3" "State" "0"
  
;disable next button
  GetDlgItem $R0 $HWNDPARENT 1
  EnableWindow $R0 0

  
;writeinistr "$PLUGINSDIR\checkSummary.ini" "FIELD 2" "State" "$ERROR_MESSAGE"
  
!insertmacro MUI_INSTALLOPTIONS_WRITE "checkSummary.ini" "FIELD 2" "State" "$ERROR_MESSAGE"

  
InstallOptions::InitDialog /NOUNLOAD "$PLUGINSDIR\checkSummary.ini"
  
  
;ReadINIStr "$0" "$PLUGINSDIR\checkSummary.ini" "FIELD 2" "HWND"
  
!insertmacro MUI_INSTALLOPTIONS_READ $"checkSummary.ini" 'Field 2' 'HWND'
  
SetCtlColors $0 0x000000 0xFFFFFF

  InstallOptions
::Show '$PLUGINSDIR\checkSummary.ini'

 
done:
FunctionEnd


Function leaveCheckSummary
 
;readinistr $'$PLUGINSDIR\checkSummary.ini' 'Settings' 'State'
 
!insertmacro MUI_INSTALLOPTIONS_READ $"checkSummary.ini" "Settings" "State"
 
${if} $== 1

 
${elseif} $== 3
   
;readinistr $'$PLUGINSDIR\checkSummary.ini' 'Field 3' 'State'
   
!insertmacro MUI_INSTALLOPTIONS_READ $"checkSummary.ini" "FIELD 3" "State"
   
${if} $== 1
    GetDlgItem $R0 $HWNDPARENT 1
    EnableWindow $R0 1
   
${else}
    
GetDlgItem $R0 $HWNDPARENT 1
    EnableWindow $R0 0
   
${endif}
  
abort
 
${endif}
FunctionEnd
    

Function .onInit

 initpluginsdir
 gettempfilename 
$0
 rename 
$'$PLUGINSDIR\checksummary.ini'
 
call WriteIni

  
;initialise $for error handling
  strcpy 
$"false"

 
!insertmacro MUI_LANGDLL_DISPLAY

 
;Check Version-Number
 call CheckADVersion
 
 
;Read InstallDir
 call GetInstallDir
 StrCpy $INSTDIR 
"$R0"
 
StrCpy $INSTDIR "..."
 
 
;Check Simatic Version-Number
 call CheckSimaticVersion

 
;CheckWindow
FunctionEnd


InstallDirRegKey HKLM 
"${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show



Section 
-Post
  WriteUninstaller 
"$INSTDIR\uninst.exe"
  
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\cmdhwconfig.exe"
  
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY"${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY"${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY"${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\cmdhwconfig.exe"
  
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY"${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY"${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY"${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd


Function GetInstallDir
 ClearErrors
 ReadRegStr $R0 HKLM 
"" "PATH"
 
IfErrors error done
 error
:
  
strcpy $"true"
  
strcpy $ERROR_MESSAGE "$ERROR_MESSAGEError while reading Install Directory from Registry.\r\n\r\n"
  
goto done
 done
:
FunctionEnd

Function CheckADVersion
 ClearErrors
 ReadRegStr $R1 HKLM 
"" "RELEASE"
 
IfErrors error noError
 error
:
  
strcpy $"true"
  
strcpy $ERROR_MESSAGE "$ERROR_MESSAGEError while reading Releasenumber of AD_Core_2006 from Registry.\r\n\r\n"
  
goto goOn
 noError
:
  
strLen $${PRODUCT_VERSION}
  
strcpy $1 $R1 $2
  strCmp 
${PRODUCT_VERSION} $1 goOn
    strcpy 
$"true"
    
strcpy $ERROR_MESSAGE "$ERROR_MESSAGEWrong Releasenumber of AD_Core_2006 (Installed: $R1; Requested: ${PRODUCT_VERSION})\r\n\r\n"
    
goto goOn
 goOn
:
   goto 
done
 done
:
FunctionEnd


Function CheckSimaticVersion
 ClearErrors
 ReadRegStr $R2 HKLM 
"" "RELEASE"
 
IfErrors error noError
 error
:
  
strcpy $"true"
  
strcpy $ERROR_MESSAGE "$ERROR_MESSAGEError while reading Releasenumber of  from Registry.\r\n\r\n"
  
goto goOn
 noError
:
  
strLen $${SIMATIC_VERSION}
  
strcpy $4 $R2 $3
  strCmp 
${SIMATIC_VERSION} $4 goOn
   strcpy 
$"true"
   
strcpy $ERROR_MESSAGE "$ERROR_MESSAGEWrong Releasenumber of STEP7 (Installed: $R2; Requested: ${SIMATIC_VERSION})\r\n\r\n"
   
goto goOn
 goOn
:
   goto 
done
 done
:
FunctionEnd 
Marcus1807 is offline   Reply With Quote
Old 1st February 2007, 10:22   #2
Marcus1807
Junior Member
 
Join Date: Jan 2007
Posts: 8
perhaps there is a registry key?
Marcus1807 is offline   Reply With Quote
Old 1st February 2007, 11:11   #3
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
There is no need to post your entire script here.
All you need is read the manual at 4.9.15.2 LangString
and examine the included examples languages.nsi and MultiLanguage.nsi.

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 1st February 2007, 11:35   #4
Marcus1807
Junior Member
 
Join Date: Jan 2007
Posts: 8
ok I still found the examples and looked at it.

so this has to work, or? :

PHP Code:
...
Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

Language files
 
!insertmacro MUI_LANGUAGE "German"
 
!insertmacro MUI_LANGUAGE "English"

Function .onInit

 
Select Language
 
!insertmacro MUI_LANGDLL_DISPLAY

!if ${LANG_GERMAN}
   
MessageBox MB_OK "DEUTSCH"
 
!else if ${LANG_ENGLISH}
   
MessageBox MB_OK "ENGLISCH"
 
!Endif
FunctionEnd 
but it does not...why?
Thank you
Marcus1807 is offline   Reply With Quote
Old 1st February 2007, 11:54   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
The !if statements you're using are suitable for the compiler not for installer, use LogicLib instead.

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 1st February 2007, 13:06   #6
Marcus1807
Junior Member
 
Join Date: Jan 2007
Posts: 8
ok, now I tried this:

LangString Message ${LANG_ENGLISH} "Englisch"
LangString Message ${LANG_GERMAN} "Deutsch"
...
MessageBox MB_OK $(Message)

this does not work.
Then I tried it so:

${if} ${LANG_GERMAN}
MessageBox MB_OK "DEUTSCH"
${else} ${LANG_ENGLISH}
MessageBox MB_OK "ENGLISCH"
${endif}

what on hell is going wrong?
Marcus1807 is offline   Reply With Quote
Old 1st February 2007, 13:57   #7
Marcus1807
Junior Member
 
Join Date: Jan 2007
Posts: 8
ok, now I have the mistake:

I had to move the instruction
call writeini
from .onInit to showChecksummary.
Marcus1807 is offline   Reply With Quote
Old 1st February 2007, 15:35   #8
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Once you have defined all the desired multilingual text, (custom page's header and subheader text must be added into the page's create function) you have to replace all hard coded static text (labels, groupboxes, radios etc) with the corresponding multilingual message.


Be aware when you write to ini e.g.
type=groupbox
text=$(GroupBox_Txt)

The definition must already exist, so this can't be done into .onInit function.

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
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