;             POLYGLOT 1.25
;   Installation Script - Installer 2.0
;    Author: Michal /CompLex/ Mecinski
;       (C)1998 CompLex, Shareware
; $VER: install_e 1.25 (7.1.98) CompLex


; ======== Language ==========

; Polish translation by CompLex
(if (= @app-name "Poliglota 1.25 (PL)")
(
	(set #lang "polski")
	(set #msg_os "Aby zainstalowaê i uruchomiê POLIGLOTË 1.25musisz mieê system V37 (2.0) lub wyûszy.")
	(set #msg_welc "Witaj w polskiej wersji\nskryptu instalacyjnego POLIGLOTY 1.25")
	(set #msg_mdir (cat "Czy chcesz utworzyê NOWY katalog o nazwie \"Poliglota\" (z ikonâ), "
			"do którego zostanie skopiowany "
    	    (if (= @user-level 2) "gîówny program" "program, dokumetacja i ustawienia")
			"?"
	))
	(set #help_mdir	(cat "Odpowiedz \"Tak\", jeûeli chcesz aby zostaî utworzony nowy"
			" katalog \"Poliglota\" (z ikonâ) we wskazanym miejscu.\n"
			" Jeûeli posiadasz juû taki katalog, lub chcesz zainstalowaê"
			" program w innym katalogu, odpowiedz przeczâco."
	))
	(set #msg_mdn (cat "Wybierz dysk, partycjë lub katalog, w którym zostanie"
			" utworzony nowy podkatalog \"Poliglota\"."
	))
	(set #msg_mdo (cat "Wybierz dysk, partycjë lub katalog, w którym zostanie"
			" zainstalowany program."
	))
	(set #name_pol "Poliglota")
	(set #name_polic "Poliglota.info")
	(set #name_bas "Bazy")
	(set #name_basic "Bazy.info")
	(set #name_docs "Poliglota_PL.Guide")
	(set #name_docd "Poliglota.Guide")
	(set #name_exam "Przykîady.plg")
	(set #name_defic "def_bazaplg.info")
	(set #name_defni "def_bazaplg")
	(set #name_pref "poliglota.prefs")
	(set #msg_doc "Gdzie skopiowaê dokumentacjë POLIGLOTY (plik \"Poliglota.guide\")?")
	(set #help_doc "Dokumentacja jest niezbëdna aby korzystaê z tego programu!")
	(set #msg_bases (cat "Czy utworzyê nowy katalog o nazwie \"Bazy\" do przechowywania"
			" baz danych Poligloty?"
	))
	(set #help_bases (cat "Jeôli odpowiesz twierdzâco, zostanie utworzony (we wskazanym miejscu)"
			" nowy katalog o nazwie \"Bazy\" z ikonâ.\n"
			"Jeôli nie, bëdziesz musiaî wybraê istniejâcy katalog."
	))
	(set #msg_bsn "Wybierz miejsce, w którym zostanie utworzony nowy katalog \"Bazy\"")
	(set #msg_bso "Wybierz katalog, w którym bëdâ przechowywane bazy danych")
	(set #msg_pref "Gdzie majâ byê zapisane ustawienia Poligloty (plik poliglota.prefs)?")
    (set #help_pref (cat "Nie warto uûywaê EnvArc, Poliglota zapisuje ustawienia od razu"
			" na dysk. Najlepsze miejsce to katalog Poligloty lub S."
	))
	(set #msg_icon "Czy chcesz, aby bazy danych byîy zapisywane wraz z ikonâ?")
	(set #help_icon	(cat "Jeûeli chcesz uruchamiaê Poliglotë z Workbecha, moûesz wybraê"
			" tworzenie ikony dla kaûdej bazy. Za pomocâ takiej ikony moûesz"
			" automatycznie uruchomiê Poliglotë.\n"
			"Z Shell/Cli niepotrzebne sâ ikony bazy, ale sam program musi jâ"
			" mieê (zapisane sâ tam ôcieûki dostëpu!)"
	))
	(set #msg_defic "Gdzie ma byê zapisana domyôlna ikona bazy danych o nazwie \"def_bazaplg.info\" ?")
    (set #msg_info (cat "Gîówny program zostanie zainstalowany w katalogu \"%s\","
			" dokumentacja w \"%s\", przykîadowa baza danych w \"%s\"."
	))
	(set #msg_paths (cat "W ikonie programu zostanâ teraz zapisane ôcieûki dostëpu"
			" do programu, katalogu baz i ikony domyôlnej (lub jej brak)."
			" Jeûeli przeniesiesz jakâô czëôê pakietu, bëdziesz musiaî je zmieniê"
			" (patrz dokumentacja)."
	))
	(set #msg_loc "Czy chcesz, aby Poliglota uûywaî jëzyka polskiego?")
	(set #help_loc (cat "Jeôli chcesz, aby wszystkie komunikaty byîy po polsku,"
			" trzeba bëdzie zainstalowaê polskie tîumaczenie (catalog).\n"
			"W przeciwnym wypadku, program bëdzie uûywaî wbudowanego jëzyka"
			" angielskiego."
	))
	(set #msg_lib "Skopiujë bibliotekë \"reqtools.library\" do katalogu Libs:")
	(set #help_lib (cat "Biblioteka jest niezbëdna do dziaîania programu. Skopiuj jâ,"
		" jeûeli twoja wersja jest starsza lub nie masz jej."
	))
	(set #msg_end (cat "Program nie ma jeszcze zapisanych ustawieï. Uruchom Poliglotë"
	" z Workbencha i wybierz opcjë Zapisz w oknie Ustawienia.\n"
	"Szczegóîowe informacje na temat uûywania programu znajdziesz w dokumentacji."
	" Pomocna bëdzie takûe zainstalowana w katalogu baz przykîadowa baza opisana"
	" w dokumentacji.\n\n"
	"Ûyczë wielu sukcesów w uûywaniu Poligloty!"
	))
)
;Default English language
(
	(set #lang "english")
	(set #msg_os "You must have OS V37 (2.0) or more to run and install Polyglot.")
	(set #msg_welc "Welcome to the English version\nof POLYGLOT 1.25 Installation Script")
	(set #msg_mdir (cat "Do you want to create a NEW directory called 'Polyglot' (with icon), "
			"where the "
			(if (= @user-level 2) "main program" "program, documetation and settings")
			" will be installed?")
	)
	(set #help_mdir	(cat "Answer 'Yes', if you want a new directory created"
			" called 'Polyglot' (with an icon) in selected place.\n"
			" If a directory already exists or you want the program"
			" installed in another directory, say 'No'."
	))
	(set #msg_mdn (cat "Select a disk, partition or directory, in which"
			" a new 'Polyglot' subdirectory will be created."
	))
	(set #msg_mdo (cat "Select a disk, partition or directory, in which"
			" the program will be installed."
	))
	(set #name_pol "Polyglot")
	(set #name_polic "Polyglot.info")
	(set #name_bas "Bases")
	(set #name_basic "Bases.info")
	(set #name_docs "Polyglot_ENG.Guide")
	(set #name_docd "Polyglot.Guide")
	(set #name_exam "Examples.plg")
	(set #name_defic "def_plgbase.info")
	(set #name_defni "def_plgbase")
	(set #name_pref "polyglot.prefs")
	(set #msg_doc "Where should the POLYGLOT documentation ('Polyglot.guide' file) be copied?")
	(set #help_doc "The documentation is necessary to use this program!")
	(set #msg_bases (cat "Do you want to create a NEW directory called 'Bases' (with icon), "
			" for Polyglot bases?")
	)
	(set #help_bases (cat "If you answer 'Yes', a new directory called"
			" 'Bases' (with an icon) will be created in selected place.\n"
			" If not, you'll have to select an existing directory."
	))
	(set #msg_bsn "Select a place, where a new 'Bases' directory will be created")
	(set #msg_bso "Select a directory in which the data bases will be stored.")
	(set #msg_pref "Where should the Polyglot preferences be saved ('polyglot.prefs' file)?")
    (set #help_pref (cat "Don't use EnvArc, because Polyglot will save prefs"
			" to the disk at once. A best place is Polyglot home dir or S dir."
	))
	(set #msg_icon "Do you want the bases saved with their icons?")
	(set #help_icon	(cat "If you want to run Polyglot from Workbench, you may"
			" select creating an icon for every base. You can run Polyglot"
			" automatically with a base icon then.\n"
			"From Shell/Cli the base icons are unnecessary, but the program"
			" must have one (paths are stored there!)"
	))
	(set #msg_defic "Where should be the default base icon ('def_plgbase.info') copied?")
    (set #msg_info (cat "The main program will be installed in the '%s' directory,"
			" documentation in '%s', example data base in '%s'."
	))
	(set #msg_paths (cat "Now, I will save paths of the program, bases"
			" directory and default info (if exists) to the program"
			" icon. You'll have to change them manually if you move"
			" anything (see documentation)."
	))
	; locale not used in English mode, just for translators
	(set #msg_loc "Do you want the Polyglot use xxx language?")
	(set #help_loc (cat "If you want all messages etc. in the program in xxx language,"
			" the xxx locale must be installed.\n"
			"Else, the program will use built-in English."
	))
	(set #msg_lib "I will copy the 'reqtools.library' to your Libs: directory")
	(set #help_lib (cat "This library is necessary for the program. Copy it,"
		" if you have older or no reqtools.library."
	))
	(set #msg_end (cat "The program has no prefs yet. Run Polyglot"
	" from Workbench and select Save option in Preferences window.\n"
	"All information about using the program may be found in the documentation."
	" The example database will be also usefull - it's installed in your bases directory."
	" (see documentation for more info).\n\n"
	"I wish you using the Polyglot successfully!"
	))
))

; ======== Check OS version ========

(if (< (/ (getversion) $10000) 37)
	(abort #msg_os)
)

(complete 0)

(set #instd (pathonly @icon))

(welcome #msg_welc)

; ========== Main dir ========

(set #mainc
	(askbool
		(prompt #msg_mdir)
		(help #help_mdir)
    )
)

(set #maind
	(askdir
		(prompt
			(if #mainc #msg_mdn #msg_mdo)
		)
		(help @askdir-help)
		(default "Sys:")
		(disk)
	)
)

; ---- Must be created now ----

(if #mainc
	(
		(makedir (tackon #maind #name_pol))
		(copyfiles
			(source (cat #instd ".info"))
			(dest #maind)
			(newname #name_polic)
			(nogauge)
		)
		(set #maind (tackon #maind #name_pol))
	)
)

(set @default-dest #maind)
(complete 10)

; ========= Expert: Documentation ========

(if (= @user-level 2)
(set #docd
	(askdir
		(prompt #msg_doc)
		(help #help_doc)
		(default #maind)
	)
)
(set #docd #maind)
)

(complete 20)

; ========= Bases dir ======

(set #basc
	(askbool
		(prompt #msg_bases)
		(help #help_bases)
	)
)

(set #basd
	(askdir
		(prompt
			(if #basc #msg_bsn #msg_bso)
		)
		(help @askdir-help)
		(default #maind)
	)
)
; ----- create the dir now -------
(if #basc
	(
		(makedir (tackon #basd #name_bas))
		(copyfiles
			(source (tackon #instd "Bases.info"))
			(dest #basd)
			(newname #name_basic)
			(nogauge)
		)
		(set #basd (tackon #basd #name_bas))
	)
)

(complete 30)

; ========= EXPERT: place for settings =======
(if (= @user-level 2)
(
	(set #pred
		(askdir
			(prompt #msg_pref)
            (help #help_pref)
			(default #maind)
		)
	)
	(complete 40)
)
(set #pred #maind)
)
; ========== Workbench-support? =========
(set #icoc
	(askbool
		(prompt #msg_icon)
		(help #help_icon)
	)
)

; ======== EXPERT: default base icon =======
(if #icoc
	(if (= @user-level 2)
		(
        	(set #icod
				(askdir
					(prompt #msg_defic)
					(help @askdir-help)
					(default #basd)
				)
			)
    	)
		(set #icod #basd)
	)
)

(complete 55)


; ======== Polish locale? =======

(if (<> #lang "english")
	(set #loc
		(askbool
			(prompt #msg_loc)
			(help #help_loc)
		)
	)
	(set #loc 0)
)
(if #loc
	(if (exists "Locale:" (noreq))
		(set #locd (cat "Locale:Catalogs/" #lang))
		(set #locd (tackon #maind (cat "catalogs/" #lang)))
	)
)

(complete 60)

; ============ COPY FILES ===========

; --- Information ---
(message (#msg_info #maind #docd #basd))

; --- Program and documentation ---
(copyfiles
	(source (tackon #instd "Polyglot"))
	(dest #maind)
	(newname #name_pol)
	(infos)
)

(copyfiles
	(source (tackon #instd (cat "Docs/" #name_docs)))
	(dest #docd)
	(newname #name_docd)
	(infos)
)
; --- Bases (with or without icons) ---
(if #icoc
	(
		(copyfiles
			(source (tackon #instd (cat "Bases/" #name_exam)))
			(dest #basd)
			(infos)
		)
		(copyfiles
			(source (tackon #instd "Bases/def_plgbase.info"))
			(dest #icod)
			(newname #name_defic)
		)
	)
	(
		(copyfiles
			(source (tackon #instd (cat "Bases/" #name_exam)))
			(dest #basd)
		)
	)
)
; --- Locale ----
(if #loc
	(if (exists "Locale:" (noreq))
		(
			(makedir "Locale:Catalogs")
			(makedir (cat "Locale:Catalogs/" #lang))
			(copyfiles
				(source (tackon #instd (cat "catalogs/" #lang "/polyglot.catalog")))
				(dest (cat "Locale:Catalogs/" #lang))
            )
		)
		(
			(makedir (tackon #maind "catalogs"))
			(makedir (tackon #maind (cat "catalogs/" #lang)))
			(copyfiles
				(source (tackon #instd (cat "catalogs/" #lang "/polyglot.catalog")))
				(dest (tackon #maind (cat "catalogs/" #lang)))
            )
		)
	)
)

(complete 75)

; ========= ToolTypes Setting (paths) ========

(message #msg_paths)

(working)

(tooltype
	(dest (tackon #maind #name_pol))
	(if #icoc
		(settooltype "ICON" (tackon #icod #name_defni))
		(settooltype "ICON")
	)
	(settooltype "DIR" #basd)
	(settooltype "PREFS" (tackon #pred #name_pref))
	(if #loc (settooltype "LANGUAGE" #lang))
)
(if #icoc
	(
		(tooltype
			(dest (tackon #basd #name_exam))
			(setdefaulttool (tackon #maind #name_pol))
        )
		(tooltype
			(dest (tackon #icod #name_defni))
			(setdefaulttool (tackon #maind #name_pol))
        )
	)
)
(complete 85)

; ======== ReqTools.library =======
(set #temp @user-level)
(user 2)

(copylib
	(prompt #msg_lib)
	(help #help_lib)
	(source (tackon #instd "libs/reqtools.library"))
	(dest "Libs:")
	(confirm)
)

(user #temp)

; ====== END ======

(complete 95)

(message #msg_end)

(complete 100)
