Archive: To extract a file only if a given language was selected...


To extract a file only if a given language was selected...
Hiya, i want the leia-me.txt file to be extracted only if the user choose PortugueseBR and the readme.txt file to be extracted only if the user selected English, how would i do it?!


Check the value of $LANGUAGE.


Sorry Joost, but i didn't get it. =|


Use this code

;readme files - replace xxxx with the language code for PortugueseBR 
StrCmp $LANGUAGE 1033 0 +2
file readme.txt
StrCmp $LANGUAGE xxxx 0 +2
file leia-me.txt
;rest of script

Vytautas

Thank you, Joost and Vytautas ...


Okk, it worked fine but now i have another problem. After i finish compiling my installer, i get many warnings like this:

Generating language tables... warning: LangString "MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX" is not set in language table of language 1033
...

And when i run the file, it shows no texts.

Please, help meee! ;)


1033 is the language ID of English. You can also use ${LANG_ENGLISH} instead, that's easier. For PortugueseBR use ${LANG_PORTUGUESEBR}.

If you get this error, you have probably used an English language string without including the MUI_LANGUAGE macro for English.


I included the macro for both languages but i still get this error. I think something is in the wrong order, but i've changed it many times and couldn't make it work. I'll post the first lines of my script here and hope you can help me. ;)

!include "MUI.nsh"

!define NAME "Jackal Counter-Strike Pack"
!define VERSION "v1.0"
!define MUI_ICON "${NSISDIR}\contrib\graphics\icons\classic-install.ico"
!define MUI_UNICON "${NSISDIR}\contrib\graphics\icons\classic-uninstall.ico"
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
!define MUI_LANGDLL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\JCP"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\cstrike\$(README)"
!define MUI_FINISHPAGE_SHOWREADME_TEXT $(SHOWREADME)
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_RUN "$INSTDIR\hl.exe"
!define MUI_FINISHPAGE_RUN_PARAMETERS "-console -game cstrike -noforcemaccel -noforcemparms +localinfo mm_gamedll podbot/podbot.dll"
!define MUI_FINISHPAGE_RUN_TEXT $(RUNTEXT)
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION $(TD)
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\contrib\graphics\header\win.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "${NSISDIR}\contrib\graphics\header\win.bmp"

!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "English"

Name "${NAME}"

XPStyle on
CRCCheck off
SetOverwrite on
SetFont Tahoma 8
ShowInstDetails nevershow
ShowUninstDetails nevershow
OutFile "C:\1_dc\apps\jcp10.exe"
InstallDirRegKey HKLM "Software\Valve\Half-Life" "InstallPath"

Function .onInit

!insertmacro MUI_LANGDLL_DISPLAY
InitPluginsDir
File /oname=$PLUGINSDIR\splash.bmp "C:\1_dc\pack\installer\imagens\splash.bmp"
advsplash::show 3000 600 400 -1 $PLUGINSDIR\splash
Pop $0

FunctionEnd

Function .onVerifyInstDir

IfFileExists $INSTDIR\hl.exe PathGood
Abort
PathGood:

FunctionEnd

Caption "$(I1) ${NAME} ${VERSION}"
UninstallCaption "$(I2) ${NAME} ${VERSION}"
BrandingText "${NAME} $(I3) Nullsoft Scriptable Install System"

!insertmacro MUI_PAGE_LICENSE "C:\1_dc\pack\hl\cstrike\licenca.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES

LangString RUNTEXT ${LANG_PORTUGUESEBR} "Executar CS?"
LangString SHOWREADME ${LANG_PORTUGUESEBR} "Deseja ver o leia-me?"
LangString TD ${LANG_PORTUGUESEBR} "Caso o diretório do HL não esteja certo, insira a localização correta."
LangString I1 ${LANG_PORTUGUESEBR} "Instalação:"
LangString I2 ${LANG_PORTUGUESEBR} "Desinstalação:"
LangString I3 ${LANG_PORTUGUESEBR} "distribuído pelo"
LangString README ${LANG_PORTUGUESEBR} "leia-me.txt"
LangString RUNTEXT ${LANG_ENGLISH} "Run CS?"
LangString SHOWREADME ${LANG_ENGLISH} "Do you wish to see the readme?"
LangString TD ${LANG_ENGLISH} "If the HL directory shown below isn't right, select the right path."
LangString I1 ${LANG_ENGLISH} "Instalation:"
LangString I2 ${LANG_ENGLISH} "Uninstalation:"
LangString I3 ${LANG_ENGLISH} "packed by"
LangString README ${LANG_ENGLISH} "readme.txt"
LangString DP1 ${LANG_PORTUGUESEBR} "Fazendo cópia de segurança..."
LangString DP2 ${LANG_PORTUGUESEBR} "Copiando arquivos de base..."
LangString DP3 ${LANG_PORTUGUESEBR} "Inserindo chaves do registro..."
LangString BANNER1 ${LANG_PORTUGUESEBR} "$\r$\n$\r$\n> Servidor rodando:$\r$\n> ${NAME} ${VERSION} @ jcp.sharewith.us"
LangString SHORTCUT1 ${LANG_PORTUGUESEBR} "Leia-me.lnk"
LangString SHORTCUT2 ${LANG_PORTUGUESEBR} "Desinstalador.lnk"
LangString DP1 ${LANG_ENGLISH} "Making backup..."
LangString DP2 ${LANG_ENGLISH} "Copying base files..."
LangString DP3 ${LANG_ENGLISH} "Inserting registry keys..."
LangString BANNER1 ${LANG_ENGLISH} "$\r$\n$\r$\n> Server running:$\r$\n> ${NAME} ${VERSION} @ jcp.sharewith.us"
LangString SHORTCUT1 ${LANG_ENGLISH} "Readme.lnk"
LangString SHORTCUT2 ${LANG_ENGLISH} "Uninstall.lnk"


Indeed. The page macros should be before the MUI_LANGUAGE macros.

Some other notes:

You don't have to add SetFont Tahoma 8. NSIS 2 uses the Windows system font by default (the sytem font of modern Windows versions is Tahoma).

The Modern UI automatically sets XPStyle to on.