Very advanced internationalisation
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:
[list=1][*]make the installer available in multilangue (done by MUI_RESERVEFILE_LANGDLL and MUI_LANGUAGE)[*]make the license file available in more than on language (done by MUI_PAGE_CUSTOMFUNCTION_SHOW and language strings containing the filename)[*]take the choosen language from the installer, and precheck it (done by MUI_PAGE_CUSTOMFUNCTION_SHOW and "!insertmacro SelectSection ${SEC0001}")[*]take the choosen language from the installer, put the language file in InstType "standard" (how to say which group schould be added by SF_SECGRP ???)[*]delete the non-use InstType when the language is english (Is it possible to 'delete' an InstType at runtime [$(inst_minimal) or $(inst_standard)] if the user chooses english, I tried CB_DELETESTRING but it seems that the wrong string is deleted?)[/list=1]
I use the following code (with InstTypes as shown before )
...
!define LIC_NAME $(lic_filename)
...
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_SHOW addLicense
!insertmacro MUI_PAGE_LICENSE ..\bin\Release\lizenz.rtf # some file has to stand here, the right language file is choosen dynamically
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MySpecialLanguageThings
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILESES
# Installer languages
!insertmacro MUI_LANGUAGE German
!insertmacro MUI_LANGUAGE English
!insertmacro MUI_LANGUAGE French
...
Function addLicense
# addLicence shows the right licence file instead allowing only one via MUI_PAGE_LICENSE
ClearErrors
System::Call 'kernel32::CreateFile(t "$EXEDIR\${LIC_NAME}", i ${GENERIC_READ}, i ${FILE_SHARE_READ}, i 0, i ${OPEN_EXISTING}, i 0, i 0) i .r0'
IfErrors exit
System::Call 'kernel32::GetFileSize(i r0, i 0) i .r1'
IntOp $1 $1 + 1 ; for terminating zero
System::Alloc $1
Pop $2
System::Call 'kernel32::ReadFile(i r0, i r2, i r1, *i .r3, i 0)'
System::Call 'kernel32::CloseHandle(i r0)'
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1000
SendMessage $0 ${WM_SETTEXT} $0 $2
System::Free $2
exit:
FunctionEnd
...
# 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 MyOnGuiInit
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 MySpecialLanguageThings
# delete not used InstType if language is English
# does not work... deletes the wrong string - no custom anymore
${If} $(SEC0000_NAME) == "Main Program"
Push $R0
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1017
SendMessage $R0 ${CB_DELETESTRING} 3 $(inst_standard)
Pop $R0
${Else}
# selecting installer sections (languages)
# adding to a group does not work in this way...
${If} $(SEC0001_NAME) == "Deutsch"
!insertmacro SetSectionFlag ${SEC0001} SF_SECGRP
!insertmacro SelectSection ${SEC0001}
${Else}
${If} $(SEC0002_NAME) == "Français"
!insertmacro SetSectionFlag ${SEC0002} SF_SECGRP
!insertmacro SelectSection ${SEC0002}
${EndIf}
${EndIf}
${EndIf}
FunctionEnd
LangString SEC0000_NAME ${LANG_ENGLISH} "Main Program"
LangString SEC0000_NAME ${LANG_GERMAN} "Hauptprogramm"
LangString SEC0000_NAME ${LANG_FRENCH} "Programme"
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"
LangString lic_filename ${LANG_ENGLISH} "..\bin\Release\license.rtf"
LangString lic_filename ${LANG_GERMAN} "..\bin\Release\lizenz.rtf"
# no licence file for French yet --> we take the english one
LangString lic_filename ${LANG_FRENCH} "..\bin\Release\license.rtf"