; Install PhotoFolio catalogs
; $VER: Install-PF_Catalogs V1.0 (3.5.2000)
; © 2000 Paul Huxham

(set #catalog 0) ; english language is default

; Find the current language
(set #i 0)
(while (set #thisfile (select #i
		"english" "italiano" "deutsch" "español" "czech" "català" "dansk" "français"
		"hrvatski" "nederlands" "norsk" "polski" "português"
		"russian" "srpski" "suomi" "svenska" "ÃeÓtina"
		""))
	(
		(if (= @language #thisfile)
			(
				(set #catalog #i)
				(set #catalogname #thisfile)
			)
		)
		(set #i (+ #i 1))
	)
)

; Query user for their language, using system as default
(set #catalog
	(askchoice
		(prompt "Select your native language (language for installer)")
		(help @askoptions-help)
		(choices "English" "Italiano" "Deutsch" "Español" "Czech")
		(default #catalog)
	)
)

; Reset #catalogname as the user may have changed the language above
(if (< #catalog 5)
	(
		(set #catalogname (select #catalog "english" "italiano" "deutsch" "español" "czech"))
	)
)

; Some string defaults common for all languages
(set #HOMEPAGE "http://mafeking.scouts.org.au/photofolio")
(set #BLANK "\n")


; ************************** English texts ******************************
(set #INITIAL_MESSAGE
  (cat "\nWelcome to the PhotoFolio catalog installer\n\n\n"
	"You can obtain updates, mailing list and other information\nabout PhotoFolio at the PhotoFolio homepage\n"
	#HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nYou need at least version 42.9 of Installer\nto install PhotoFolio catalogs")
(set #PROMPT_INSTALL_CATALOG "\nWhich language catalogs would you like to install?")
(set #INSTALLING_CATALOG "\nInstalling PhotoFolio catalog")
(set #UPDATES_AVAILABLE "\nUpdates of PhotoFolio and its required libraries\n\nare available from the PhotoFolio home page")

; ************************** Italiano texts *****************************
(if (= #catalog 1)
(
(set #INITIAL_MESSAGE
  (cat "\nBenvenuto nell'installazione di PhotoFolio catalogs\n\n\n"
     "Puoi ottenere gli aggiornamenti, la mailing list e altre informazioni\nsu PhotoFolio alla homepage\n"
     #HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nNecessiti almeno della versione 42.9 dell'Installer\nper installare PhotoFolio")
(set #PROMPT_INSTALL_CATALOG "\nQuale catalogo della lingua desideri installare?")
(set #INSTALLING_CATALOG "\nInstallazione catalogo PhotoFolio")
(set #UPDATES_AVAILABLE "\nAggiornamenti di PhotoFolio e le librarie richieste\n\nsono disponibili sulla home page")
)
)

; ************************** Deutsch texts ******************************
(if (= #catalog 2)
(
(set #INITIAL_MESSAGE
  (cat "\nWillkommen zur Installation von PhotoFolio catalogs\n\n\n"
    "Updates, und weitere Information\nüber PhotoFolio gibt es auf der Homepage\n"
    #HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nSie benötigen mind. Version 42.9 des Installers\num PhotoFolio zu installieren")
(set #PROMPT_INSTALL_CATALOG "\nWelche Sprachen wollen Sie installieren?")
(set #INSTALLING_CATALOG "\nPhotoFolio Sprachdatei wird installiert")
(set #UPDATES_AVAILABLE "\nUpdates für PhotoFolio und den dazugehörigen libraries\n\ngibt es auf der Homepage")
)
)

; ************************** Español texts ******************************
(if (= #catalog 3)
(
(set #INITIAL_MESSAGE
  (cat "\nBienvenido a la instalación de PhotoFolio catalogs\n\n\n"
	"Podrás obtener actualizaciones, acceder a listas de correo y tener más información\nsobre PhotoFolio en la página web de Homepage\n"
	#HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nNecesitas al menos la versión 42.9 del Installer\npara instalar PhotoFolio")
(set #PROMPT_INSTALL_CATALOG "\n¿Qué catalogos (lenguajes) quieres instalar?")
(set #INSTALLING_CATALOG "\nInstalando catálogo de PhotoFolio")
(set #UPDATES_AVAILABLE "\nLas actualizaciones de PhotoFolio catalogs y librerías necesarias\n\nestán disponibles en la página web de homepage")
)
)

; ************************** Czech texts ******************************
(if (= #catalog 4)
(
(set #INITIAL_MESSAGE
  (cat "\nVítejte pêi instalaci programu PhotoFolio catalogs!\n\n\n"
	"Dalîí informace, kontakt na ostatní uùivatele a aktualizace\nmûùete zdarma získat staùením z domovské stránky\n"
	#HOMEPAGE)
)
(set #WRONG_INSTALLER_VERSION "\n\n\n\nK instalaci programu PhotoFolio\npotêebujete Installer V42.9 nebo vyîîí")
(set #PROMPT_INSTALL_CATALOG "\nKterý z pêekladû chcete nainstalovat?")
(set #INSTALLING_CATALOG "\nInstalace pêekladu programu PhotoFolio")
(set #UPDATES_AVAILABLE "\n\nAktualizace programu PhotoFolio a pêísluîných\n\nknihoven jsou dostupné z domovské stránky")
)
)


; *********************** PhotoFolio catalog install

(if (< @installer-version (+ (* 65536 42) 9))
	(abort #WRONG_INSTALLER_VERSION)
)

; All essential version numbers are correct, continue installation
(message #INITIAL_MESSAGE)

(complete 0)


; *********************** Install locale catalog

(set #localedest "LOCALE:Catalogs")

(if (<> #catalog 0)
	(
		(set #localesrc 1) ; Defaults to first entry
		(set #i 0)
		(while (set #thiscat (select #i "italiano" "deutsch" "czech" "français" "nederlands" ""))
			(
				(if (= #catalogname #thiscat)
					(
						(set #x #i)
						(while (> #x 0)
							(set #localesrc (* #localesrc 2))

							(set #x (- #x 1))
						)
					)
				)

				(set #i (+ #i 1))
			)
		)
	)
	(
		(set #localesrc 0)
	)
)

(set #installcat
	(askoptions
		(prompt #PROMPT_INSTALL_CATALOG)
		(choices "Italiano" "Deutsch" "Czech" "Français" "Nederlands")
		(default #localesrc)
		(help @askoptions-help)
	)
)

(set #i 0)
(while (< #i 5)
	(set #x #i)
	(set #y 1)

	(while (> #x 0)
		(set #y (* #y 2))

		(set #x (- #x 1))
	)

	(if (bitand #installcat #y)
		(
			(set #localecat (select #i "Italiano" "Deutsch" "Czech" "Français" "Nederlands"))

			(copyfiles
				(prompt (cat (cat #INSTALLING_CATALOG " " ) #localecat))
				(help @copyfiles-help)
				(source (tackon "Catalogs" #localecat))
				(choices "PhotoFolio.catalog")
				(dest (tackon #localedest #localecat))
				(confirm)
				(optional askuser)
				(files)
			)
		)
	)

	(set #i (+ #i 1))
)

(complete 100)


; Finished installation
(message (cat #UPDATES_AVAILABLE #BLANK #BLANK #HOMEPAGE))
