Die Dokumentation für dieses Modul kann unter Modul:Benutzer:Vollbracht/Bibel/Doku erstellt werden

--[=[ Bibel 2023-01-21
	Module for various provider bible references
	Autor: Vollbracht
]=]

local transCode = {
	-- book number by automatically simplified name entry = bookData key
	-- noncanonical books not (to be) simplified
	tcBk = {
		['1CHR'] = 13, ['1COR'] = 56, ['1Chr'] = 13, ['1Cor'] = 56,
		['1JOH'] = 72, ['1Joh'] = 72, ['1KGS'] = 11, ['1Kgs'] = 11,
		['1KOR'] = 56, ['1Kor'] = 56, ['1KÖN'] = 11, ['1Kön'] = 11,
		['1MAK'] = 45, ['1MO'] = 1, ['1Mak'] = 45, ['1Mo'] = 1,
		['1PAR'] = 13, ['1PET'] = 70, ['1Par'] = 13, ['1Pet'] = 70,
		['1SAM'] = 9, ['1Sam'] = 9, ['1THE'] = 62, ['1TIM'] = 64, ['1The'] = 62,
		['1Tim'] = 64, ['2CHR'] = 14, ['2COR'] = 57, ['2Chr'] = 14,
		['2Cor'] = 57, ['2JOH'] = 73,  ['2Joh'] = 73, ['2KGS'] = 12,
		['2KOR'] = 57, ['2Kgs'] = 12, ['2Kor'] = 57, ['2KÖN'] = 12,
		['2Kön'] = 12, ['2MAK'] = 46, ['2MO'] = 2, ['2Mak'] = 46, ['2Mo'] = 2,
		['2PAR'] = 14, ['2PET'] = 71, ['2Par'] = 14, ['2Pet'] = 71,
		['2SAM'] = 10, ['2Sam'] = 10, ['2THE'] = 63, ['2TIM'] = 65,
		['2The'] = 63, ['2Tim'] = 65, ['3ESD'] = 89, ['3ESR'] = 89,
		['3Esd'] = 89, ['3Esr'] = 89, ['3JOH'] = 74, ['3Joh'] = 74,
		['3MAK'] = 87, ['3MO'] = 3, ['3Mak'] = 87, ['3Mo'] = 3,
		['4MAK'] = 88, ['4MO'] = 4, ['4Mak'] = 88, ['4Mo'] = 4,
		['5MO'] = 5, ['5Mo'] = 5,
		ACT = 54, AM = 30, APG = 54, Act = 54, Am = 30, Apg = 54, Apo = 54,
		BAR = 44, BEL = 86, Bar = 44, Bel = 86,
		CAN = 22, COL = 61, Can = 22, Col = 61,
		DAN = 27, DEU = 5, Dan = 27, Deu = 5, Dtn = 5,
		EPH = 59, ESR = 15, EST = 17, EX = 2, EZ = 26, EZR = 15,
		Ecc = 21, Eph = 59, Esr = 15, Est = 17, Ex = 2, Ez = 26, Ezr = 15,
		GAL = 58, GEN = 1,
		Gal = 58, ['Gebet Manasses'] = 49, ['Gebet von Manasse'] = 49, Gen = 1,
		HAB = 35, HAG = 37, HEB = 68, HES = 26, HI = 18, HLD = 22, HOH = 22,
		HOS = 28, Hab = 35, Hag = 37, Heb = 68, Hes = 26, Hi = 18, Hld = 22,
		Hoh = 22, Hos = 28,
		IJOB = 18, Ijob = 18, Ion = 32, Isa = 23,
		JAK = 69, JDT = 40, JER = 24, JES = 23, JOEL = 29, JOH = 53, JON = 32,
		JOS = 6, JUD = 75, Jak = 69, Jam = 69, Jas = 69, Jdt = 40, Jer = 24,
		Jes = 23, Job = 18, Joel = 29, Joh = 53, Jon = 32, Jos = 6, Jud = 75,
		Judg = 7, Judi = 40,
		KLA = 25, KLG = 25, KOH = 21, KOL = 61,
		Kla = 25, Klg = 25, Koh = 21, Kol = 61,
		LEV = 3, LK = 52, LUK = 52, Lam = 25, Lev = 3, Lk = 52, Luk = 52,
		MAL = 39, MAT = 50, MAR = 51, MI = 33, MT = 50, MK = 51,
		Mal = 39, Mat = 50, Mar = 51, Mi = 33, Mt = 50, Mk = 51,
		NAH = 34, NEH = 16, NUM = 4, Nah = 34, Neh = 16, Num = 4,
		OBA = 31, OBD = 31, OFF = 76, Oba = 31, Obd = 31, Off = 76,
		PHI = 60, PHLM = 67, PRD = 21, PRE = 21, PRO = 20, PS = 19,
		Phi = 60, Phlm = 67, Prd = 21, Pre = 21, Pro = 20, Prv = 20, Ps = 19,
		RI = 7, RU = 8, Rev = 76, Ri = 7, Rom = 55, Ru = 8, ['RÖM'] = 55,
		['Röm'] = 55,
		SAC = 38, SIR = 43, SPR = 20,
		Sac = 38, Sap = 41, Sir = 43, Sofia = 41, Sofonias = 42, Son = 22,
		Sophia = 41, Sophonias = 36, Spr = 20, ['Stücke zu Daniel'] = 48,
		['Stücke zu Ester'] = 47, Su = 85,
		TIT = 66, TOB = 42, Tit = 66, Tob = 42,
		WEI = 41, Wei = 41, Wis = 41,
		ZEF = 36, ZEP = 36, Zac = 38, Zec = 38, Zef = 36, Zep = 36
	},
	-- variant keys for provider selection
	tcPrv = {
		1, 2, 3,
		BS = 2, BW = 1, DBG = 1, ERF = 2, Q875742 = 1, Q1275774 = 2,
		Q7860447 = 3, STEP = 3, TH = 3,
		bs = 2, -- published
		bw = 1, -- published
		dbg = 1, -- Deutsche Bibelgesellschaft = bibelwissenschaft.de
		erf = 2, -- erf = bibleserver.com
		step = 3, -- published
		th = 3 -- Tyndale House = stepbible.org
	}
}

--[[
	biblical book data
	Entry numbers are a foreign key. Do not alter (remove or insert elements
	atween) unless you know what you are doing!
	key (number)	Bibelwissenschaft.de key by Deutsche Bibelgesellschaft
					and transCode.tcBk number
	vl1		array of currently up to three values:
			  Q875742: Bibelwissenschaft.de key by Deutsche Bibelgesellschaft
			  Q7860447: STEPbible.org key by Tyndale House, Cambridge
			  Q1275774: bibleserver.de key by Evangeliumsrundfunk erf
	wd		Wikidata key
	group	one out of currently 5 values:
			  Q19786: OT, canonical
			  Q18813: NT, canonical
			  Q201410: OT, deuterocanonical
			  Q29334: Septuaginta ("LXX", OT), not canonical
			  Q116215829: Stuttgart Vulgata V, not canonical
	de		title with link
]]
local bookData = {
	-- group = 'Q19786' is OT, canonical
	{ -- 1
		vl1 = { Q875742 = 1, Q7860447 = 'Gen', Q1275774 = 'Gen' },
		vl2 = 'Genesis', wd = 'Q9184', group = 'Q19786', wp = 'Genesis (Bibel)',
		de = "Buch [[Genesis]] (1. Buch Mose)"
	},
	{ -- 2
		vl1 = { Q875742 = 2, Q7860447 = 'Exod', Q1275774 = 'Ex' },
		vl2 = 'Exodus', wd = 'Q9190', group = 'Q19786', wp = 'Exodus (Bibel)',
		de = "Buch [[Exodus (Bibel)|Exodus]] (2. Buch Mose)"
	},
	{ -- 3
		vl1 = { Q875742 = 3, Q7860447 = 'Lev', Q1275774 = 'Lev' },
		vl2 = 'Levitikus', wd = 'Q41490', group = 'Q19786', wp = 'Levitikus',
		de = "Buch [[Levitikus]] (3. Buch Mose)"
	},
	{ -- 4
		vl1 = { Q875742 = 4, Q7860447 = 'Num', Q1275774 = 'Num' },
		vl2 = 'Numeri', wd = 'Q43099', group = 'Q19786', wp = 'Numeri',
		de = "Buch [[Numeri]] (4. Buch Mose)"
	},
	{ -- 5
		vl1 = { Q875742 = 5, Q7860447 = 'Deut', Q1275774 = 'Dtn' },
		vl2 = 'Deuteronomium', wd = 'Q42614', group = 'Q19786',
		wp = 'Deuteronomium', de= "[[Deuteronomium]] (5. Buch Mose)"
	},
	{ -- 6
		vl1 = { Q875742 = 6, Q7860447 = 'Josh', Q1275774 = 'Jos' },
		vl2 = 'Josua', wd = 'Q47680', group = 'Q19786', wp = 'Buch Josua',
		de = "[[Buch Josua]]"
	},
	{ -- 7
		vl1 = { Q875742 = 7, Q7860447 = 'Judg', Q1275774 = 'Ri' },
		vl2 = 'Richter', wd = 'Q81240', group = 'Q19786',
		wp = 'Buch der Richter', de = "[[Buch der Richter]]"
	},
	{ -- 8
		vl1 = { Q875742 = 8, Q7860447 = 'Ruth', Q1275774 = 'Rut' },
		vl2 = 'Rut', wd = 'Q80038', group = 'Q19786', wp = 'Buch Rut',
		de = "[[Buch Rut]]"
	},
	{ -- 9
		vl1 = { Q875742 = 9, Q7860447 = '1Sam', Q1275774 = '1.Sam' },
		vl2 = '1.Samuel', wd = 'Q1975029', group = 'Q19786',
		wp = '1. Buch Samuel', de = "[[1. Buch Samuel]]"
	},
	{ -- 10
		vl1 = { Q875742 = 10, Q7860447 = '2Sam', Q1275774 = '2.Sam' },
		vl2 = '2.Samuel', wd = 'Q209719', group = 'Q19786',
		wp = '2. Buch Samuel', de = "[[2. Buch Samuel]]"
	},
	{ -- 11
		vl1 = { Q875742 = 11, Q7860447 = '1Kgs', Q1275774 = '1.Kng' },
		vl2 = '1.Könige', wd = 'Q131066', group = 'Q19786',
		wp = '1. Buch der Könige', de= "[[1. Buch der Könige]]"
	},
	{ -- 12
		vl1 = { Q875742 = 12, Q7860447 = '2Kgs', Q1275774 = '2.Kng' },
		vl2 = '2.Könige', wd = 'Q209746', group = 'Q19786',
		wp = '2. Buch der Könige', de= "[[2. Buch der Könige]]"
	},
	{ -- 13
		vl1 = { Q875742 = 13, Q7860447 = '1Chr', Q1275774 = '1.Chr' },
		vl2 = '1.Chronik', wd = 'Q9813916', group = 'Q19786',
		wp = '1. Buch der Chronik', de= "[[1. Buch der Chronik]]"
	},
	{ -- 14
		vl1 = { Q875742 = 14, Q7860447 = '2Chr', Q1275774 = '2.Chr' },
		vl2 = '2.Chronik', wd = 'Q209720', group = 'Q19786',
		wp = '2. Buch der Chronik', de= "[[2. Buch der Chronik]]"
	},
	{ -- 15
		vl1 = { Q875742 = 15, Q7860447 = 'Ezra', Q1275774 = 'Esra' },
		vl2 = 'Esra', wd = 'Q131635', group = 'Q19786', wp = 'Buch Esra',
		de= "[[Buch Esra]]"
	},
	{ -- 16
		vl1 = { Q875742 = 16, Q7860447 = 'Neh', Q1275774 = 'Neh' },
		vl2 = 'Nehemia', wd = 'Q131640', group = 'Q19786', wp = 'Buch Nehemia',
		de= "[[Buch Nehemia]]"
	},
	{ -- 17
		vl1 = { Q875742 = 17, Q7860447 = 'Esth', Q1275774 = 'Est' },
		vl2 = 'Ester', wd = 'Q131068', group = 'Q19786', wp = 'Buch Ester',
		de = "[[Buch Ester]]"
	},
	{ -- 18
		vl1 = { Q875742 = 18, Q7860447 = 'Job', Q1275774 = 'Hiob' },
		vl2 = 'Ijob', wd = 'Q4577', group = 'Q19786', wp = 'Ijob',
		de = "Buch [[Ijob]]"
	},
	{ -- 19
		vl1 = { Q875742 = 19, Q7860447 = 'Ps', Q1275774 = 'Ps' },
		vl2 = 'Psalm', wd = 'Q41064', group = 'Q19786',
		wp = 'Buch der Psalmen', de = "[[Buch der Psalmen]]"
	},
	{ -- 20
		vl1 = { Q875742 = 20, Q7860447 = 'Prov', Q1275774 = 'Spr' },
		vl2 = 'Sprüche', wd = 'Q4579', group = 'Q19786',
		wp = 'Buch der Sprichwörter',
		de = "[[Buch der Sprichwörter]] (Sprüche Salomos)"
	},
	{ -- 21
		vl1 = { Q875742 = 21, Q7860447 = 'Eccl', Q1275774 = 'Pred' },
		vl2 = 'Prediger', wd = 'Q131072', group = 'Q19786', wp = 'Kohelet',
		de = "Buch [[Kohelet]] (Prediger Salomo)"
	},
	{ -- 22
		vl1 = { Q875742 = 22, Q7860447 = 'Hld', Q1275774 = 'Hld' },
		vl2 = 'Hoheslied', wd = 'Q51670', group = 'Q19786', wp = 'Hoheslied',
		de = "[[Hoheslied|Hohelied]] Salomos (Lied der Lieder)"
	},
	{ -- 23
		vl1 = { Q875742 = 23, Q7860447 = 'Isa', Q1275774 = 'Jes' },
		vl2 = 'Jesaja', wd = 'Q131458', group = 'Q19786', wp = 'Jesaja',
		de = "Buch [[Jesaja]]"
	},
	{ -- 24
		vl1 = { Q875742 = 24, Q7860447 = 'Jer', Q1275774 = 'Jer' },
		vl2 = 'Jeremia', wd = 'Q131590', group = 'Q19786', wp = 'Jeremia',
		de = "Buch [[Jeremia]]"
	},
	{ -- 25
		vl1 = { Q875742 = 25, Q7860447 = 'Lam', Q1275774 = 'Klgl' },
		vl2 = 'Klagelieder', wd = 'Q179058', group = 'Q19786',
		wp = 'Klagelieder Jeremias',
		de = "Buch der [[Klagelieder Jeremias|Klagelieder]]"
	},
	{ -- 26
		vl1 = { Q875742 = 26, Q7860447 = 'Ezek', Q1275774 = 'Hes' },
		vl2 = 'Ezechiel', wd = 'Q178390', group = 'Q19786', wp = 'Ezechiel',
		de = "Buch [[Ezechiel]] (Hesekiel)"
	},
	{ -- 27
		vl1 = { Q875742 = 27, Q7860447 = 'Dan', Q1275774 = 'Dan' },
		vl2 = 'Daniel', wd = 'Q80115', group = 'Q19786', wp = 'Daniel',
		de = "Buch [[Daniel]]"
	},
	{ -- 28
		vl1 = { Q875742 = 28, Q7860447 = 'Hos', Q1275774 = 'Hos' },
		vl2 = 'Hosea', wd = 'Q184030', group = 'Q19786', wp = 'Hosea',
		de = "Buch [[Hosea]]"
	},
	{ -- 29
		vl1 = { Q875742 = 29, Q7860447 = 'Joel', Q1275774 = 'Joel' },
		vl2 = 'Joel', wd = 'Q131643', group = 'Q19786', wp = 'Joel',
		de = "Buch [[Joel]]"
	},
	{ -- 30
		vl1 = { Q875742 = 30, Q7860447 = 'Amos', Q1275774 = 'Am' },
		vl2 = 'Amos', wd = 'Q174677', group = 'Q19786', wp = 'Amos',
		de = "Buch [[Amos]]"
	},
	{ -- 31
		vl1 = { Q875742 = 31, Q7860447 = 'Obad', Q1275774 = 'Obd' },
		vl2 = 'Obadja', wd = 'Q174753', group = 'Q19786', wp = 'Obadja',
		de = "Buch [[Obadja]]"
	},
	{ -- 32
		vl1 = { Q875742 = 32, Q7860447 = 'Jonah', Q1275774 = 'Jona' },
		vl2 = 'Jona', wd = 'Q178819', group = 'Q19786', wp = 'Jona',
		de = "Buch [[Jona]]"
	},
	{ -- 33
		vl1 = { Q875742 = 33, Q7860447 = 'Mic', Q1275774 = 'Mic' },
		vl2 = 'Micha', wd = 'Q178076', group = 'Q19786', wp = 'Micha',
		de = "Buch [[Micha]]"
	},
	{ -- 34
		vl1 = { Q875742 = 34, Q7860447 = 'Nah', Q1275774 = 'Nah' },
		vl2 = 'Nahum', wd = 'Q179755', group = 'Q19786', wp = 'Nahum',
		de = "Buch [[Nahum]]"
	},
	{ -- 35
		vl1 = { Q875742 = 35, Q7860447 = 'Hab', Q1275774 = 'Hab' },
		vl2 = 'Habakuk', wd = 'Q179760', group = 'Q19786', wp = 'Habakuk',
		de = "Buch [[Habakuk]]"
	},
	{ -- 36
		vl1 = { Q875742 = 36, Q7860447 = 'Zeph', Q1275774 = 'Zef' },
		vl2 = 'Zefanja', wd = 'Q188563', group = 'Q19786', wp = 'Zefanja',
		de = "Buch [[Zefanja]]"
	},
	{ -- 37
		vl1 = { Q875742 = 37, Q7860447 = 'Hag', Q1275774 = 'Hag' },
		vl2 = 'Haggai', wd = 'Q178338', group = 'Q19786', wp = 'Haggai',
		de = "Buch [[Haggai]]"
	},
	{ -- 38
		vl1 = { Q875742 = 38, Q7860447 = 'Zech', Q1275774 = 'Sac' },
		vl2 = 'Sacharja', wd = 'Q179769', group = 'Q19786', wp = 'Sacharja',
		de = "Buch [[Sacharja]]"
	},
	{ -- 39
		vl1 = { Q875742 = 39, Q7860447 = 'Mal', Q1275774 = 'Mal' },
		vl2 = 'Maleachi', wd = 'Q51675', group = 'Q19786', wp = 'Maleachi',
		de = "Buch [[Maleachi]]"
	},
	-- group = 'Q201410' is OT deuterocanonical'
	{ -- 40
		vl1 = { Q875742 = 40, Q1275774 = 'Judit' },
		vl2 = 'Judit', wd = 'Q41064', group = 'Q201410', wp = 'Buch Judit',
		de = "[[Buch Judit]]"
	},
	{ -- 41
		vl1 = { Q875742 = 41, Q7860447 = 'Weisheit', Q1275774 = 'Weisheit' },
		vl2 = 'Weisheit', wd = 'Q202135', group = 'Q201410',
		wp = 'Buch der Weisheit', de = "[[Buch der Weisheit]] Salomos"
	},
	{ -- 42
		vl1 = { Q875742 = 42, Q7860447 = 'Tobit', Q1275774 = 'Tobit' },
		vl2 = 'Tobit', wd = 'Q131737', group = 'Q201410', wp = 'Buch Tobit',
		de = "[[Buch Tobit]]"
	},
	{ -- 43
		vl1 = { Q875742 = 43, Q7860447 = 'Sirach', Q1275774 = 'Sirach' },
		vl2 = 'Sirach', wd = 'Q155980', group = 'Q201410', wp = 'Jesus Sirach',
		de = "Buch [[Jesus Sirach]] (Weisheit Sirachs)"
	},
	{ -- 44
		vl1 = { Q875742 = 44, Q1275774 = 'Baruch' },
		vl2 = 'Baruch', wd = 'Q211746', group = 'Q201410', wp = 'Baruch',
		de = "Buch [[Baruch]]"
	},
	{ -- 45
		vl1 = { Q875742 = 45, Q1275774 = '1.Mak' },
		vl2 = '1.Makkabäer', wd = 'Q161985', group = 'Q201410',
		wp = '1. Buch der Makkabäer', de = "[[1. Buch der Makkabäer]]"
	},
	{ -- 46
		vl1 = { Q875742 = 46, Q1275774 = '2.Mak' },
		vl2 = '2.Makkabäer', wd = 'Q209748', group = 'Q201410',
		wp = '2. Buch der Makkabäer', de = "[[2. Buch der Makkabäer]]"
	},
	{ -- 47
		vl1 = { Q875742 = 47 },
		vl2 = 'Stücke zu Ester', wd = 'Q5615312', group = 'Q201410',
		wp = 'Stücke zum Buch Ester', de = "[[Stücke zum Buch Ester]]"
	},
	{ -- 48
		vl1 = { Q875742 = 48 },
		vl2 = 'Stücke zu Daniel', wd = 'Q116199760', group = 'Q29334',
		wp = 'Daniel#Christentum',
		de = "Stücke zum Buch [[Daniel#Christentum|Daniel]]"
	},
	-- group = Q29334 is LXX, not canonical
	{ -- 49
		vl1 = { Q875742 = 49 },
		vl2 = 'Gebet Manasses', wd = 'Q41064', group = 'Q29334',
		wp = 'Gebet des Manasse', de = "[[Gebet des Manasse]]"
	},
	-- group = Q18813 is NT, canonical
	{ -- 50
		vl1 = { Q875742 = 50, Q7860447 = 'Matt', Q1275774 = 'Mt' },
		vl2 = 'Matthäus', wd = 'Q392302', group = 'Q18813',
		wp = 'Evangelium nach Matthäus',
		de = "[[Evangelium nach Matthäus]]"
	},
	{ -- 51
		vl1 = { Q875742 = 51, Q7860447 = 'Mark', Q1275774 = 'Mk' },
		vl2 = 'Markus', wd = 'Q107388', group = 'Q18813',
		wp = 'Evangelium nach Markus',
		de = "[[Evangelium nach Markus]]"
	},
	{ -- 52
		vl1 = { Q875742 = 52, Q7860447 = 'Luke', Q1275774 = 'Lk' },
		vl2 = 'Lukas', wd = 'Q39939', group = 'Q18813',
		wp = 'Evangelium nach Lukas', de = "[[Evangelium nach Lukas]]"
	},
	{ -- 53
		vl1 = { Q875742 = 53, Q7860447 = 'John', Q1275774 = 'Joh' },
		vl2 = 'Johannes', wd = 'Q36766', group = 'Q18813',
		wp = 'Evangelium nach Johannes',
		de = "[[Evangelium nach Johannes]]"
	},
	{ -- 54
		vl1 = { Q875742 = 54, Q7860447 = 'Acts', Q1275774 = 'Apg' },
		vl2 = 'Apostelgeschichte', wd = 'Q41064', group = 'Q18813',
		wp = 'Apostelgeschichte des Lukas',
		de = "[[Apostelgeschichte des Lukas]]"
	},
	{ -- 55
		vl1 = { Q875742 = 55, Q7860447 = 'Rom', Q1275774 = 'Rom' },
		vl2 = 'Römer', wd = 'Q48203', group = 'Q18813',
		wp = 'Brief des Paulus an die Römer',
		de = "[[Brief des Paulus an die Römer]]"
	},
	{ -- 56
		vl1 = { Q875742 = 56, Q7860447 = '1Cor', Q1275774 = '1.Kor' },
		vl2 = '1.Korinther', wd = 'Q80355', group = 'Q18813',
		wp = '1. Brief des Paulus an die Korinther',
		de = "[[1. Brief des Paulus an die Korinther]]"
	},
	{ -- 57
		vl1 = { Q875742 = 57, Q7860447 = '2Cor', Q1275774 = '2.Kor' },
		vl2 = '2.Korinther', wd = 'Q123808', group = 'Q18813',
		wp = '2. Brief des Paulus an die Korinther',
		de = "[[2. Brief des Paulus an die Korinther]]"
	},
	{ -- 58
		vl1 = { Q875742 = 58, Q7860447 = 'Gal', Q1275774 = 'Gal' },
		vl2 = 'Galater', wd = 'Q128620', group = 'Q18813',
		wp = 'Brief des Paulus an die Galater',
		de = "[[Brief des Paulus an die Galater]]"
	},
	{ -- 59
		vl1 = { Q875742 = 59, Q7860447 = 'Eph', Q1275774 = 'Eph' },
		vl2 = 'Epheser', wd = 'Q408673', group = 'Q18813',
		wp = 'Brief des Paulus an die Epheser',
		de = "[[Brief des Paulus an die Epheser]]"
	},
	{ -- 60
		vl1 = { Q875742 = 60, Q7860447 = 'Phil', Q1275774 = 'Phil' },
		vl2 = 'Philipper', wd = 'Q51613', group = 'Q18813',
		wp = 'Brief des Paulus an die Philipper',
		de = "[[Brief des Paulus an die Philipper]]"
	},
	{ -- 61
		vl1 = { Q875742 = 61, Q7860447 = 'Col', Q1275774 = 'Kol' },
		vl2 = 'Kolosser', wd = 'Q131095', group = 'Q18813',
		wp = 'Brief des Paulus an die Kolosser',
		de = "[[Brief des Paulus an die Kolosser]]"
	},
	{ -- 62
		vl1 = { Q875742 = 62, Q7860447 = '1Thess', Q1275774 = '1.Thes' },
		vl2 = '1.Thessalonicher', wd = 'Q131115', group = 'Q18813',
		wp = '1. Brief des Paulus an die Thessalonicher',
		de = "[[1. Brief des Paulus an die Thessalonicher]]"
	},
	{ -- 63
		vl1 = { Q875742 = 63, Q7860447 = '2Thess', Q1275774 = '2.Thes' },
		vl2 = '2.Thessalonicher', wd = 'Q131107', group = 'Q18813',
		wp = '2. Brief des Paulus an die Thessalonicher',
		de = "[[2. Brief des Paulus an die Thessalonicher]]"
	},
	{ -- 64
		vl1 = { Q875742 = 64, Q7860447 = '1Tim', Q1275774 = '1.Tim' },
		vl2 = '1.Timotheus', wd = 'Q131180', group = 'Q18813',
		wp = '1. Brief des Paulus an Timotheus',
		de = "[[1. Brief des Paulus an Timotheus]]"
	},
	{ -- 65
		vl1 = { Q875742 = 65, Q7860447 = '2Tim', Q1275774 = '2.Tim' },
		vl2 = '2.Timotheus', wd = 'Q131489', group = 'Q18813',
		wp = '2. Brief des Paulus an Timotheus',
		de = "[[2. Brief des Paulus an Timotheus]]"
	},
	{ -- 66
		vl1 = { Q875742 = 66, Q7860447 = 'Titus', Q1275774 = 'Tit' },
		vl2 = 'Titus', wd = 'Q131493', group = 'Q18813',
		wp = 'Brief des Paulus an Titus',
		de = "[[Brief des Paulus an Titus]]"
	},
	{ -- 67
		vl1 = { Q875742 = 67, Q7860447 = 'Phlm', Q1275774 = 'Phlm' },
		vl2 = 'Philemon', wd = 'Q131104', group = 'Q18813',
		wp = 'Brief des Paulus an Philemon',
		de = "[[Brief des Paulus an Philemon]]"
	},
	{ -- 68
		vl1 = { Q875742 = 68, Q7860447 = 'Heb', Q1275774 = 'Heb' },
		vl2 = 'Hebräer', wd = 'Q128608', group = 'Q18813',
		wp = 'Brief an die Hebräer', de = "[[Brief an die Hebräer]]"
	},
	{ -- 69
		vl1 = { Q875742 = 69, Q7860447 = 'Jas', Q1275774 = 'Jak' },
		vl2 = 'Jakobus', wd = 'Q131097', group = 'Q18813',
		wp = 'Brief des Jakobus', de = "[[Brief des Jakobus]]"
	},
	{ -- 70
		vl1 = { Q875742 = 70, Q7860447 = '1Pet', Q1275774 = '1.Pet' },
		vl2 = '1.Petrus', wd = 'Q131119', group = 'Q18813',
		wp = '1. Brief des Petrus', de = "[[1. Brief des Petrus]]"
	},
	{ -- 71
		vl1 = { Q875742 = 71, Q7860447 = '2Pet', Q1275774 = '2.Pet' },
		vl2 = '2.Petrus', wd = 'Q131178', group = 'Q18813',
		wp = '2. Brief des Petrus', de = "[[2. Brief des Petrus]]"
	},
	{ -- 72
		vl1 = { Q875742 = 72, Q7860447 = '1John', Q1275774 = '1.Joh' },
		vl2 = '1.Johannes', wd = 'Q131101', group = 'Q18813',
		wp = '1. Brief des Johannes', de = "[[1. Brief des Johannes]]"
	},
	{ -- 73
		vl1 = { Q875742 = 73, Q7860447 = '2John', Q1275774 = '2.Joh' },
		vl2 = '2.Johannes', wd = 'Q131453', group = 'Q18813',
		wp = '2. Brief des Johannes', de = "[[2. Brief des Johannes]]"
	},
	{ -- 74
		vl1 = { Q875742 = 74, Q7860447 = '3John', Q1275774 = '3.Joh' },
		vl2 = '3.Johannes', wd = 'Q131462', group = 'Q18813',
		wp = '3. Brief des Johannes', de = "[[3. Brief des Johannes]]"
	},
	{ -- 75
		vl1 = { Q875742 = 75, Q7860447 = 'Jude', Q1275774 = 'Judas' },
		vl2 = 'Judas', wd = 'Q131466', group = 'Q18813',
		wp = 'Brief des Judas', de = "[[Brief des Judas]]"
	},
	{ -- 76
		vl1 = { Q875742 = 76, Q7860447 = 'Rev', Q1275774 = 'Offb' },
		vl2 = 'Offenbarung', wd = 'Q42040', group = 'Q18813',
		wp = 'Offenbarung des Johannes',
		de = "[[Offenbarung des Johannes]]"
	},
	-- group = Q29334 is LXX, non canonical
	[85] = { -- 85: Daniel 13
		vl1 = { Q875742 = 85 },
		vl2 = 'Susanna', wd = Q16930210, group = Q29334,
		wp = 'Susanna im Bade',
		de = "Kapitel von [[Susanna im Bade]] (Daniel 13)"
	},
	[86] = { -- 86: Daniel 14
		vl1 = { Q875742 = 86 },
		vl2 = 'Bel und Drache', wd = Q218087, group = Q29334,
		wp = 'Bel und der Drache',
		de =	"Kapitel von [[Bel und der Drache|Bel und dem Drachen]] (Daniel"
			..	" 14)"
	},
	[87] = { -- 87: 3. Makkabäer
		vl1 = { Q875742 = 87 },
		vl2 = '3.Makkabäer', wd = Q223169, group = Q29334,
		wp = '3. Buch der Makkabäer', de = "[[3. Buch der Makkabäer]]"
	},
	[88] = { -- 88: 4. Makkabäer
		vl1 = { Q875742 = 88 },
		vl2 = '4.Makkabäer', wd = Q230255, group = Q29334,
		wp = '4. Buch der Makkabäer', de = "[[4. Buch der Makkabäer]]"
	},
	[89] = { -- 89: 3. Esra (1. Esdras, LXX)
		vl1 = { Q875742 = 89 },
		vl2 = '3.Esra', wd = Q1200049, group = Q29334, wp = '3. Esra',
		de = "[[3. Esra|3. Buch Esra]] (1. Esdras)"
	},
	[90] = { -- 90: 4. Esra
		vl1 = { Q875742 = 90 },
		vl2 = '4.Esra', wd = Q1200049, group = Q116215829,
		wp = '4. Buch Esra', de = "[[4. Buch Esra]]"
	},
	[91] = { -- 91:
		vl1 = { Q875742 = 91 },
		vl2 = 'Psalm 151', wd = Q1052253, group = Q116215829, wp = 'Psalm 151',
		de = "[[Psalm 151]]"
	},
	[92] = { -- 92:
		vl1 = { Q875742 = 92 },
		vl2 = 'Laodizener', wd = Q1052253, group = Q116215829,
		wp = 'Laodizenerbrief', de = "[[Laodizenerbrief]]"
	}
}

--[[
	translation data
	keys are shown as short link text
	title		verbous with link to source description if available
	default		provider if not explicitely selected
	available
		key is the provider offering this version
		value: available book groups in this version and access info for version
			<group key> = true - statements as of book data groups
			link	URL portion specific to provider and translation
]]
local translationData = {
	AKJV = {
		title = "[[King-James-Bibel]] 1611 ([[Amerikanisches Englisch|AE]]-Schr"
			..	"eibweise 1999)",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "AKJV" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "AKJV" },
			'Q7860447'
		}
	},
	BHS = {
		title = "[[Biblia Hebraica Stuttgartensia]]", 
		available = {
			Q875742 = {
				Q19786 = true, link = "biblia-hebraica-stuttgartensia-bhs"
			}
		},
		default = {
			{ Q19786 = true, link = "biblia-hebraica-stuttgartensia-bhs" },
			'Q875742'
		}
	},
	EU = {
		title = "[[Einheitsübersetzung]] 2016",
		available = {
			Q1275774 = {
				Q19786 = true, Q201410 = true, Q18813 = true, link = "EU"
			}
		},
		default = {
			{ Q19786 = true, Q201410 = true, Q18813 = true, link = "EU" },
			'Q1275774'
		}
	},
	Elb = {
		title = "Elberfelder Bibel 2006",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "ELB" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "ELB" },
			'Q1275774'
		}
	},
	ESV = {
		title = "English Standard Version 2016",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "ESV" },
			Q7860447 = { Q19786 = true, Q18813 = true, link = "ESV" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "ESV" }, 
			'Q7860447'
		}
	},
	ESV2002 = {
		title = "English Standard Version 2002",
		available = {
			Q875742 = {
				Q19786 = true, Q18813 = true,
				link = "english-standard-version"
			}
		},
		default = {
			{
				Q19786 = true, Q18813 = true, link = "english-standard-version"
			},
			'Q875742'
		}
	},
	GNT5 = {
		title = "United Bible Societies: ''Greek New Testament''. 5. Aufl., 201"
			..	"4",
		available = {
			Q875742 = { Q18813 = true, link = "greek-new-testament-ubs5" }
		},
		default = {
			{ Q18813 = true, link = "greek-new-testament-ubs5" },
			'Q875742'
		}
	},
	GerLut1545 = {
		title = "[[Lutherbibel#Die kursächsische Normbibel von 1581|Luther]]-Va"
			..	"riante, nach 1581",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "GerLut1545" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "GerLut1545" },
			'Q7860447'
		}
	},
	GerGruenewald = {
		title = "Grünewaldübersetzung 1924",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "GerGruenewald" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "GerGruenewald" },
			'Q7860447'
		}
	},
	GerSch = {
		title = "[[Schlachter–Bibel]] 1951",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "GerSch" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "GerSch" },
			'Q7860447'
		}
	},
	Hfa = {
		title = "''[[Hoffnung für alle]]''– Übersetzung 2015",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "HFA" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "HFA" },
			'Q1275774'
		}
	},
	KJV = {
		title = "[[King-James-Bibel]] 1769",
		available = {
			Q875742 = {
				Q19786 = true, Q18813 = true, link = "king-james-version"
			},
			Q1275774 = { Q19786 = true, Q18813 = true, link = "KJV" },
			Q7860447 = { Q19786 = true, Q18813 = true, link = "KJV" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "KJV" },
			'Q7860447'
		}
	},
	KJVA = {
		title = "[[King-James-Bibel]] mit Apokryphen, 1769",
		available = {
			Q7860447 = {
				Q18813 = true, Q19786 = true, Q201410 = true, Q29334 = true,
				link = "KJVA"
			}
		},
		default = {
			{
				Q18813 = true, Q19786 = true, Q201410 = true, Q29334 = true,
				link = "KJVA"
			},
			'Q7860447'
		}
	},
	Lut = {
		title = "[[Lutherbibel]] 2017",
		available = {
			Q1275774 = {
				Q19786 = true, Q201410 = true, Q18813 = true, link = "LUT"
			}
		},
		default = {
			{ Q19786 = true, Q201410 = true, Q18813 = true, link = "LUT" },
			'Q1275774'
		}
	},
	Lut1984 = {
		title = "[[Lutherbibel]] 1984",
		available = {
			Q875742 = {
				Q19786 = true, Q201410 = true, Q18813 = true,
				link = "luther-bibel-1984"
			}
		},
		default = {
			{
				Q19786 = true, Q201410 = true, Q18813 = true,
				link = "luther-bibel-1984"
			},
			'Q875742'
		}
	},
	LXX = {
		title = "[[Septuaginta]] (LXX)",
		available = {
			Q875742 = {
				Q19786 = true, Q201410 = true, Q29334 = true,
				link = "septuaginta-lxx"
			},
			Q7860447 = { Q19786 = true, link = "LXX" }
		},
		default = {
			{
				Q19786 = true, Q201410 = true, Q29334 = true,
				link = "septuaginta-lxx"
			},
			'Q875742'
		}
	},
	['NeÜ'] = {
		title = "Neue evangelistische Übersetzung",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "Ne%C3%9C" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "Ne%C3%9C" },
			'Q1275774'
		}
	},
	['NGÜ'] = {
		title = "[[Neue Genfer Übersetzung]]",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "NG%C3%9C" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "NG%C3%9C" },
			'Q1275774'
		}
	},
	NA28 = {
		title = "Nestle, Aland: ''[[Novum Testamentum Graece]]''. 28. Aufl., 2012",
		available = {
			Q875742 = {
				Q18813 = true, link = "novum-testamentum-graece-na-28"
			}
		},
		default = {
			{
				Q18813 = true, link = "novum-testamentum-graece-na-28"
			},
			'Q875742'
		}
	},
	NASB = {
		title = "[[New American Standard Bible]] 2020",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "NASB2020" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "NASB2020" },
			'Q7860447'
		}
	},
	NASB1995 = {
		title = "[[New American Standard Bible]] 1995",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "NASB1995" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "NASB1995" },
			'Q7860447'
		}
	},
	NIV = {
		title = "[[New International Version]] 2011",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "NIV" },
			Q7860447 = { Q19786 = true, Q18813 = true, link = "NIV" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "NIV" },
			'Q7860447'
		}
	},
	NIrV = {
		title = "New International Readers Version 2014/2021",
		available = {
			Q1275774 = { Q19786 = true, Q18813 = true, link = "NIRV" },
			Q7860447 = { Q19786 = true, Q18813 = true, link = "NIrV" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "NIV" },
			'Q7860447'
		}
	},
	OHB = {
		title = "[[Westminster Leningrad Codex]]",
		available = {
			Q7860447 = { Q19786 = true, link = "OHB" }
		},
		default = {
			{ Q19786 = true, link = "OHB" },
			'Q7860447'
		}
	},
	Slt = {
		title = "[[Schlachter-Bibel]] 2000",
		available = {
			Q1275774 = {
				Q19786 = true, Q201410 = true, Q18813 = true, link = "SLT"
			}
		},
		default = {
			{ Q19786 = true, Q201410 = true, Q18813 = true, link = "SLT" },
			'Q1275774'
		}
	},
	THGNT = {
		title = "Tyndale House [[Greek New Testament]], 2017",
		available = {
			Q7860447 = { Q18813 = true, link = "THGNT" }
		},
		default = {
			{ Q18813 = true, link = "THGNT" },
			'Q7860447'
		}
	},
	THOT = {
		title = "Translators Hebrew Old Testament, 2019",
		available = {
			Q7860447 = { Q19786 = true, link = "THOT" }
		},
		default = {
			{ Q19786 = true, link = "THOT" },
			'Q7860447'
		}
	},
	VulgCC = {
		title = "[[Vulgata Clementina]], ed. Conte 2009",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "VulgCC" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "VulgCC" },
			'Q7860447'
		}
	},
	VulgEQ = {
		title = "[[Vulgata]], ed. quinta 2007",
		available = {
			Q875742 = {
				Q19786 = true, Q18813 = true, Q201410 = true, Q29334 = true,
				Q116215829 = true, link = "biblia-sacra-vulgata"
			}
		},
		default = {
			{
				Q19786 = true, Q18813 = true, Q201410 = true, Q29334 = true,
				Q116215829 = true, link = "biblia-sacra-vulgata"
			},
			'Q875742'
		}
	},
	VulgJ = {
		title = "[[Vulgata]], Hieronimus 405",
		available = {
			Q7860447 = { Q19786 = true, Q18813 = true, link = "VulgJ" }
		},
		default = {
			{ Q19786 = true, Q18813 = true, link = "VulgJ" },
			'Q7860447'
		}
	},
	-- Wulfila = do not enter! no complete group available; usable w/o entering
	ZB = {
		title = "[[Zürcher Bibel]] 2007",
		available = {
			Q1275774 = {
				Q19786 = true, Q201410 = true, Q18813 = true, link = "ZB"
			}
		},
		default = {
			{ Q19786 = true, Q201410 = true, Q18813 = true, link = "ZB" },
			'Q1275774'
		}
	}
}
translationData.ELB = translationData.Elb
translationData.ESV2016 = translationData.ESV
translationData.KJB = translationData.KJV
translationData.HFA = translationData.Hfa
translationData.LUT = translationData.Lut
translationData.Lut1545 = translationData.GerLut1545
translationData.Lut2017 = translationData.Lut
translationData.Lut84 = translationData.Lut1984
translationData.NA = translationData.NA28
translationData.NASB2020 = translationData.NASB
translationData.NIRV = translationData.NIrV
translationData.SLT = translationData.Slt
translationData.Slt1951 = translationData.GerSch
translationData.Slt2000 = translationData.Slt
translationData.Vg = translationData.VulgEQ
translationData.Vulg = translationData.VulgEQ
translationData.WLC = translationData.OHB


--[[
	Provider
	bible text provider data object
	known entities: Q875742, Q1275774 and Q7860447 (constant members)
	fields:
		key			Wikidata item key
		name		domain name to be used for display as well
		urlForm		string for generating link
	methods:
		getPosition(chapter, verses)
			provider specific way of generating a position representation to be
			passed to the provider via URL (chapter + verses)
			parameters:
				chapter	number (mandantory)
				verses	optional 1-2 numbers hyphen separated
			returns:	single string representation for position
		getErrorMsg(base)
			generate error messages based on provider name and base infos
			parameters:
				base.err	error number 
				base.title	(err = 4, 5) title of a version
				base.vl3	(err = 5) title of a book
]]
local Provider = {
	-- Methods --
	getErrorMsg = function(this, base)
		if base.err < 4 then
			return base.full .. '[[Kategorie:Wikipedia:Qualitätssicherung Vorla'
				.. 'geneinbindung fehlerhaft]]'
		elseif Base.err == 4 then
			return 'Für ' .. base.title .. ' stellt ' .. this.name
				.. ' keine Daten bereit.[[Kategorie:Wikipedia:Qualitätssicherun'
				.. 'g Vorlageneinbindung fehlerhaft]]'
		elseif Base.err == 5 then
			return base.vl3 .. ' ist in der von ' .. this.name .. ' bereitgeste'
				.. 'llten ' .. base.title .. 'nicht verfügbar.[[Kategorie:Wikip'
				.. 'edia:Qualitätssicherung Vorlageneinbindung fehlerhaft]]'
		end
	end
}

--[[
	constructor
	Provider objects are constant members of Provider table
	parameters:
		o	all object data in a predefined struct
	returns:	the struct enriched by a method and 'self' access
]]
function Provider:new(o)
	if not o or not o.urlForm or not o.getPosition then return nil end
	local result = o
	setmetatable(result, self)
	self.__index = self
	table.insert(Provider, result) -- for numeric access
	return result
end

-- functions --

--[[
	get provider Object(<provider entry>)
	interface between transCode.tcPrv, users provider selection and provider
	object
	Parameters:
		bkEntry	distinct string representation of a provider name: shortening of
				provider or domain name or Wikidata key
	returns:	provider object (selected - not newly created)
]]
local getProviderObject = function(input)
	if not input then return nil end
	local result = transCode.tcPrv[input]
	if not result then return nil end
	return Provider[result]
end

-- provider data:
Provider.Q875742 = Provider:new({
		key = 'Q875742',
		name = 'bibelwissenschaft.de',
		getPosition = function(chapter, verses)
			if not chapter then return '10001/19999' end
			-- handle pan chapter span
			if type(chapter) == 'table' then
				local s = chapter[1]
				local e = chapter[2]
				local v = tonumber(s[1]) * 10000
				return tostring(v + tonumber(s[2])) .. '/' .. s[1] .. '9999'
			end
			chapter = tonumber(chapter) * 10000
			if verses then
				if type(verses) == 'string' then
					local v = { verses:match('(%d+)%s*%-%s*(%d+)') }
					if v and v[2] then
						return tostring(tonumber(v[1]) + chapter) .. '/'
							.. tostring(tonumber(v[2]) + chapter)
					end
					v = {verses:match('(%d+)%s*(f+)')}
					if v then
						if v[2] == 'f' then
							return tostring(tonumber(v[1]) + chapter) .. '/'
								.. tostring(tonumber(v[1]) + chapter + 1)
						elseif v[2] == 'f' then
							return tostring(tonumber(v[1]) + chapter) .. '/'
								.. tostring(chapter + 9999)
						end
					end
					verses = tonumber(verses:match('%d+')) + chapter
				elseif type(verses) == 'number' then
					verses = verses + chapter
				end
				return tostring(verses) .. '/' .. tostring(verses)
			end
			return tostring(chapter + 1) .. '/' .. tostring(chapter + 9999)
		end,
		-- urlForm: parameters: <version link>, <book link>, <position link>
		urlForm = {	'https://www.bibelwissenschaft.de/nc/online-bibeln/',
					'/lesen-im-bibeltext/bibel/text/lesen/stelle/', '/', '' }
	})
Provider.Q1275774 = Provider:new({
		key = 'Q1275774',
		name = 'bibleserver.com',
		getPosition = function(chapter, verses)
			local position = ''
			if not chapter then return '1' end
			-- handle pan chapter span
			if type(chapter) == 'table' then
				local s = chapter[1]
				local e = chapter[2]
				return s[1] .. ',' .. s[2] .. 'ff'
			end
			position = chapter
			if verses then
				verses = verses:gsub('%s', '')
				return position .. ',' .. verses
			end
			return position
		end,
		-- urlForm: parameters: <version link>, <book link>, <position link>
		urlForm = {	'https://www.bibleserver.com/', '/', '%20', '' }
	})
Provider.Q7860447 = Provider:new({
		key = 'Q7860447',
		name = 'stepbible.org',
		getPosition = function(chapter, verses)
			local position = ''
			if not chapter then return '1' end
			-- handle pan chapter span
			if type(chapter) == 'table' then
				local s = chapter[1]
				local e = chapter[2]
				return s[1] .. ':' .. s[2] .. '-' .. e[1] .. ':' .. e[2]
			end
			position = chapter
			if verses then
				verses = verses:gsub('%s', '')
				return position .. ':' .. verses
			end
			return position:gsub(',', ':')
		end,
		urlForm = {	"https://www.stepbible.org/?q=version=", "%7Creference=",
					'%20', "&display=INTERLEAVED" }
	})

--[[
	Book object
	fields:
		number	as of as of bookData / bibelwissenschaft.de key
		vl1		URL book representation (array with one value per provider)
		vl2		book label (short form)
		de		book title (long form with link to wiki)
		wd		Wikidata item key (currently unused)
		group	most significant Wikidata item P361 (part of) property value
	Methods:
		Book:versionLists(version) - description below
]]
local Book = {
	--[[
		Book:versionLists(version)
		parses and refines version string
		parameters:
			this	Book object or bookData entry
			version	comma separated list of version keys
		returns:	struct with version link portion per provider or 
					struct with err message
	]]
	versionLists = function(this, version)
		if version and version ~= '' then
			local list = mw.text.split(version, '%p%s?')
			if #list == 1 then
				local td = translationData[version]
				if td then
					local result = {
						err =	this.de .. ' steht in ' .. version
							..	' nicht zur Verfügung.'
					}
					for k, list in pairs(td.available) do
						if list[this.group] then
							result[k] = version
							result.err = nil
						end
					end
					return result
				end
				-- single unknown version (not in bibelwissenschaft.de)
				return { Q7860447 = version, Q1275774 = version }
			end
			-- multiple versions (not in bibelwissenschaft.de)
			local prov = { Q7860447 = {}, Q1275774 = {} }
			for _, ver in ipairs(list) do
				local td = translationData[ver]
				if td then
					-- test found known version for providing this book
					for k, __ in pairs(prov) do
						local groups = td.available[k]
						if groups and groups[this.group] then
							table.insert(prov[k], ver)
						else
							prov[k] = nil
							if not prov.Q7860447 and not prov.Q1275774 then
								return { err = 'Kein Anbieter stellt '
											.. table.concat(list, '.')
											.. ' mit [[' .. this.wp
											.. ']] zur Verfügung!' }
							end
						end
					end
				else
					-- add unknown version
					if prov.Q7860447 then table.insert(prov.Q7860447, ver) end
					if prov.Q1275774 then table.insert(prov.Q1275774, ver) end
				end
			end
			if prov.Q7860447 then
			  prov.Q7860447 = table.concat(prov.Q7860447, '%7Cversion=')
			end
			if prov.Q1275774 then
				prov.Q1275774 = table.concat(prov.Q1275774, '.')
			end
			return prov
		else
			-- no version given; return all available
			-- (unused; not needed yet)
			return nil
		end
	end
}

--[[
	constructor
	parameters:
		name	<book entry> -	distinct string representation of a book name:
								short name or usual shortening
]]
function Book:new(name)
	-- get book number section:
	local defFull = name:match('%s?Buch d?e?r?%s?')
	if not defFull then defFull = name:match(' voll') end
	if defFull then name = name:gsub(defFull, ' ') end
	local n = transCode.tcBk[name]
	if not n then n = transCode.tcBk[mw.ustring.sub(name, 1, 4)] end
	if not n then n = transCode.tcBk[mw.ustring.sub(name, 1, 3)] end
	if not n then n = transCode.tcBk[mw.ustring.sub(name, 1, 2)] end
	if not n then
		local t = {mw.ustring.match(name, '(%d)%.?%s?(%u%l%l?)')}
		if t and t[2] then
			t = table.concat(t)
			n = transCode.tcBk[t]
			if not n then n = transCode.tcBk[t:sub(1, 3)] end
		end
	end
	if not n then n = transCode.tcBk[mw.ustring.match(name, '^%S+')] end
	if not n then return nil end
	-- object construction section
	local result = bookData[n]
	result.number = n
	if defFull then
		result.label = result.de
	else
		local n = #name - #result.vl2
		n = n * n
		if n < 2 then
			result.label = result.vl2
		else
			result.label = result.vl1.Q1275774
			if not result.label then result.label = result.vl1.Q7860447 end
			if not result.label then result.label = result.vl2 end
		end
	end
	local la = { result.label:match('(%d%.)(%u.*)') }
	if la[2] then result.label = la[1] .. '&nbsp;' .. la[2] end
	setmetatable(result, self)
	self.__index = self
	return result
end

--[[
	get a string for availability of providers
	parameters
		tab	table where keys are wd provider keys
		p1	string for bibelwissenschaft only
		p2	string for additional bibleserver
		p3	string for all 3 providers
		p1b	string for bibleserver only
		p1c	string for stepbible only
		p2b	string for bibleserver and stepbible
		p2c	string for bibelwissenschaft and stepbible
]]
getAvailableString = function(tab, p1, p2, p3, p1b, p1c, p2b, p2c, p0)
	if tab.Q7860447 then
		if tab.Q1275774 then
			if tab.Q875742 then return p3
			else return p2b end
		else
			if tab.Q875742 then return p2c
			else return p1c end
		end
	elseif tab.Q1275774 then
		if tab.Q875742 then return p2
		else return p1b end
	elseif tab.Q875742 then return p1 end
	return p0
end

local p = {
}

--[[
	{{#invoke:Bibel|allBooks}}
	list all books known to this module
]]
p.allBooks = function(frame)
	local result = '{| class="wikitable zebra references"\n|+ Liste der biblisc'
				.. 'hen und einiger [[Apokryphen|apokrypher]] Bücher'
				.. '\n! colspan="2" style="text-align:right;" | Verfügbarkeit:'
				.. '\n! rowspan="2" style="writing-mode: vertical-rl; text-ori'
				.. 'entation: mixed;padding: 0 1em 0 0;"|'
				.. Provider.Q875742.name
				.. '|| rowspan="2" style="writing-mode: vertical-rl; text-orie'
				.. 'ntation: mixed;padding: 0 1em 0 0;" |'
				.. Provider.Q1275774.name
				.. '|| rowspan="2" style="writing-mode: vertical-rl; text-orie'
				.. 'ntation: mixed;padding: 0 1em 0 0;" |'
				.. Provider.Q7860447.name .. '\n|-\n! Buch || Titel\n'
	for _, v in ipairs(bookData) do
		result =	result .. '\n|- id="' .. (v.vl1.Q1275774 or v.vl2)
				..	'"\n| ' .. (v.vl1.Q1275774 or v.vl2)
				..	' ||<span class="reference-text">' .. v.de .. '</span> || '
				..	getAvailableString(v.vl1, 'x|| ||', 'x||x||', 'x||x||x')
	end
	for i = 85, 92 do
		local v = bookData[i]
		result =	result .. '\n|- id="' .. (v.vl1.Q1275774 or v.vl2)
				..	'"\n| ' .. (v.vl1.Q1275774 or v.vl2)
				..	' ||<span class="reference-text">' .. v.de .. '</span> || '
				..	getAvailableString(v.vl1, 'x|| ||', 'x||x||', 'x||x||x')
	end
	return frame:preprocess(result .. '\n|}')
end

--[[
	{{#invoke:Bibel|validBk|<book name>}}
	list a single book if known to this module; error otherwise
]]
p.validBk = function(frame)
	local book = frame.args.book
	if not book then book = frame.args[1] end
	if not book then
		local args = frame:getParent().args
		book = args.book
		if not book then book = args[1] end
		if not book then return '<span style="color:red">Kein Buch angegeben.<'
							..	'/span>[[Kategorie:Wikipedia:Qualitätssicherun'
							..	'g Vorlageneinbindung fehlerhaft]]'
		end
	end
	local b = Book:new(book)
	if not b then
		return '<span style="color:red">Kein Buch "' .. book
			.. '" im Modul STEP bekannt!</span>[[Kategorie:'
			.. 'Wikipedia:Qualitätssicherung Vorlageneinbindung fehlerhaft]]'
	end
	local result =	'{{Literatur/mit Anker|Titel=' .. b.de .. ' |ID=' .. b.vl2
			  ..	' |Kommentar=Quellen verfügbar unter '
			  ..	getAvailableString(	v.vl1,
										Provider.Q875742.name,
										Provider.Q875742.name .. ' und '
									..	Provider.Q1275774.name,
										Provider.Q875742.name .. ', '
									..	Provider.Q1275774.name .. ' und '
									..	Provider.Q7860447.name)
	return frame:preprocess(result .. ' }}')
end

p.knownVersions = function(frame)
	local result = '{| class="wikitable zebra sortable references"\n|+ Liste d'
				.. 'er im Modul bereits bekannten Bibelversionen'
				.. '\n! colspan="2" style="text-align:right;" | Verfügbarkeit:'
				.. '\n! rowspan="2" style="writing-mode: vertical-rl; text-ori'
				.. 'entation: mixed;padding: 0 1em 0 0;"|'
				.. Provider.Q875742.name
				.. '|| rowspan="2" style="writing-mode: vertical-rl; text-orie'
				.. 'ntation: mixed;padding: 0 1em 0 0;" |'
				.. Provider.Q1275774.name
				.. '|| rowspan="2" style="writing-mode: vertical-rl; text-orie'
				.. 'ntation: mixed;padding: 0 1em 0 0;" |'
				.. Provider.Q7860447.name
				.. '\n|-\n! Schlüssel || Beschreibung\n'
	for k, v in pairs(translationData) do
		result =	result .. '\n|- id="' .. k .. '"\n| ' .. k
				..	' || class="reference-text" | ' ..	v.title .. ' || '
				..	getAvailableString(	v.available,
										'x|| ||', 'x||x||', 'x||x||x', ' ||x||',
										' || ||x', ' ||x||x', 'x|| ||x')
	end
	return frame:preprocess(result .. '\n|}')
end

--[[
	frameRed(text)
	enrich an error text
	parameters:
		text	string to be enriched or
				table with an optional err field that has to be enriched
	returns:	table with an enriched err field or unalterred table
]]
local function frameRed(text)
	if type(text) ~= 'table' then
		return {
			err =	'<span style="color:red">' .. text
			  ..	'</span>[[Kategorie:Wikipedia:Qualitätssicherung Vorlagene'
			  ..	'inbindung fehlerhaft]]'
		}
	end
	if text.err and not text.err:find('color.red') then
		text.err =	'<span style="color:red">' .. text.err
			  ..	'</span>[[Kategorie:Wikipedia:Qualitätssicherung Vorlagene'
			  ..	'inbindung fehlerhaft]]'
	end
	return text
end

--[[
	handle named and unnamed args
	get necessary common data for link to bible full text
	parameters:
		version		optional short string key
					default: EU if within its scope; Lut1984 otherwise
		provider	optional Wikidata key for external link target domain
					default: wherever given version is available
		link		optional version url part if version is unknown here
					default: copy of version
	returns struct:
		vl1			book link for provider
		vl2			dep. short book name
		vl3			dep. full book name with link
		link		translation link
		version		short translation name
		title		full translation name with link
		provider	Wikidata key for external link target domain
		err			error number if not all other parameters could be provided
]]
local function parseArgs(frame)
	local result = {}
	local args = frame.args
	result.book = args.book
	local i = 1
	if args[1] and args[1]:find('%u') and not result.book then
		result.book = args[1]
		i = 2
	end
	if not result.book then
		args = frame:getParent().args
		result.book = args.book
		if args[1] and args[1]:find('%u') and not result.book then
			result.book = args[1]:match('^%s*(%S.*%S)%s*$')
			i = 2
		end
		if not result.book then return frameRed('Kein Buch angegeben.') end
	end
	local b = Book:new(result.book)
	if not b then
		return frameRed('Kein Buch "' .. result.book
					..	'" im Modul:Bibel bekannt!')
	end
	result.book = b
	result.chapter = args.chapter
	local vls = nil
	if result.chapter then result.verses = args.verses
	-- fetch chapter & verses by # only if book has been fetched by # as well:
	elseif i == 2 and args[2] then
		if args[2] then
			local s = mw.ustring.gsub(args[2], '–', '-')
			s = {
				s:match('^%s*(%d+[%,%:]?%s*%d*)[abc]?%s*%-?%s*(%d*[%,%:]?%s*%d*'
					..	')[abc]?%s*$')
			}
			if s and s[1] then
				-- chapter and possibly more found
				i = 3
				local s1 = { s[1]:match('(%d+)[%,%:]?%s*(%d*)[abc]?') }
				if s[2] == '' then
					-- single chapter or verse found (no span)
					result.chapter = s1[1]
					if s1[2] ~= '' then
						-- Single verse found. Don't ask for verses param!
						result.verses = s1[2]:match('%d+')
					elseif args[3] then
						-- test 3rd param on being verses param
						s = mw.ustring.gsub(args[3], '–', '-')
						s = {s:match('^%s*(%d+)[abc]?%s*%-?%s*(%d*)[abc]?%s*$')}
						if s and s[2] and s[2] ~= '' then
							result.verses = table.concat(s, '-')
							i = 4
						elseif s and s[1] then
							result.verses = s[1]
							i = 4
						elseif args[3]:match('%d.*[%.%;%,].*%d') then
							return frameRed('Falsches Format! Bitte keine Liste'
										..	'n angeben.')
						else
							s = {args[3]:match('(%d+)[abc]?%s*(f+)')}
							if s and s[2] then
								result.verses = table.concat(s)
								i = 4
							end
						end
					end
				else
					-- Span found. Test end on containing a chapter!
					local s2 = { s[2]:match('(%d+)[%,%:]?%s*(%d*)[ab]?') }
					if s2[2] == '' then
						-- End is verse in same chapter
						result.chapter = s1[1]
						result.verses = s1[2] .. '-' .. s2[1]
					else
						if s1[1] == s2[1] then
							-- End is verse in same chapter
							result.chapter = s1[1]
							result.verses = s1[2] .. '-' .. s2[2]
						else
							-- End is verse in another chapter
							result.chapter = { s1, s2 }
						end
					end
				end
			elseif args[2]:match('%d.*[%.%;].*%d') then
				return frameRed('Falsches Format! Bitte keine Listen angeben.')
			end
		end
		while args[i] and (args[i] == '' or args[i]:find('^%s*$')) do
			i = i + 1
		end
		-- first ask for provider (version left out) because its distinct
		result.provider = getProviderObject(args[i])
		if not result.provider then
			-- try reading version from same arg
			vls = result.book:versionLists(args[i])
			if vls then
				-- Din't throw vls.err here! (could be provider instead)
				-- But if not vls.err then use vls, reserve its arg and try
				-- using its successor for provider.
				if not vls.err then
					i = i + 1
					result.provider = getProviderObject(args[i])
				end
			else
				vls = result.book:versionLists(args.version)
				-- rare err: throw later
			end
		end
		if not result.provider then
			if args[i] then
				if vls and vls.err then return frameRed(vls.err) end
				-- args[i] for provider available but invalid
				return frameRed('Unbekannter Anbieter: ' .. args[i])
			end
			result.provider = getProviderObject(args.provider)
		end
	else
		vls = result.book:versionLists(args.version)
		result.provider = getProviderObject(args.provider)
	end
	if result.provider then
		-- args[i] available and valid provider
		result.vl1 = result.book.vl1[result.provider.key]
		if not result.vl1 then
			return frameRed(result.book.de .. ' steht bei '
						..	result.provider.name .. ' nicht zur Verfügung.')
		end
		if vls then
			-- version(s) available
			result.link = vls[result.provider.key]
			if result.link then
				if result.link:find('version') then
					result.version = 'interlinear'
					result.title = "Interlinearübersetzung"
				else
					result.version = result.link
					local td = translationData[result.link]
					if td then result.title = td.title
					else result.title = result.link .. '(unbekannt)' end
				end
				return result
			end
			for _, v in pairs(vls) do
				return frameRed(result.book.de .. ' steht in der Version ' .. v
							..	' bei '.. result.provider.name
							..	' nicht zur Verfügung.')
			end
		end
		-- no version was given
		if result.provider == Provider.Q1275774 then
			if result.book.group == 'Q19786'
			or result.book.group == 'Q18813'
			or result.book.group == 'Q201410' then
				local td = translationData.EU
				result.link = td.available.Q1275774.link
				result.version = 'EU'
				result.title = td.title
				return result
			end
			return frameRed(result.book.de
					  ..	' ist auf bibleserver.com nicht verfügbar.')
		elseif provider == Provider.Q875742 then
			local td = translationData.Lut1984
			result.link = td.available.Q875742.link
			result.version = 'Lut1984'
			result.title = td.title
			return result
		elseif result.book.group == 'Q19786' then
			result.link = 'OHB%7Cversion=NASB2020%7Cversion=GerSch'
		elseif result.book.group == 'Q18813' then
			result.link = 'THGNT%7Cversion=NASB2020%7Cversion=GerSch'
		end
		result.version = 'interlinear'
		result.title = "Interlinearübersetzung"
	else
		-- -> no provider given
		if vls then
			-- version given
			if vls.err then return frameRed(vls.err) end
			-- return best provider
			if vls.Q7860447 then
				-- 1. interlinear available and biggest number of versions
				result.link = vls.Q7860447
				if result.link:find('version') then
					result.version = 'interlinear'
					result.title = "Interlinearübersetzung"
				else
					result.version = result.link
					local td = translationData[result.link]
					if td then result.title = td.title
					else result.title = result.link .. '(unbekannt)' end
				end
				result.provider = Provider.Q7860447
				result.vl1 = result.book.vl1.Q7860447
			elseif vls.Q1275774 then
				-- 2. best German translations readable side by side
				result.link = vls.Q1275774
				result.version = result.link
				if result.link:find('%p') then
					result.title = "Parallelanzeige"
				else
					local td = translationData[result.link]
					if td then result.title = td.title
					else result.title = result.link .. '(unbekannt)' end
				end
				result.provider = Provider.Q1275774
				result.vl1 = result.book.vl1.Q1275774
			else
				-- (happens for single known version only)
				-- 3. biggest number of books in high qualitiy versions
				local td = translationData[vls.Q875742]
				result.link = td.available.Q875742.link
				result.version = vls.Q875742
				result.title = td.title
				result.provider = Provider.Q875742
				result.vl1 = result.book.vl1.Q875742
			end
		-- no version given else cases:
		elseif result.book.group == 'Q19786'
		or result.book.group == 'Q18813'
		or result.book.group == 'Q201410' then
			local td = translationData.EU
			result.link = td.available.Q1275774.link
			result.version = 'EU'
			result.title = td.title
			result.provider = Provider.Q1275774
			result.vl1 = result.book.vl1.Q1275774
		else
			local td = translationData.Lut1984
			result.link = td.available.Q875742.link
			result.version = 'Lut1984'
			result.title = td.title
			result.provider = Provider.Q875742
			result.vl1 = result.book.vl1.Q875742
		end -- version or not; any book group
	end -- provider or not
	return result
end

--[[
	=> Vorlage:Bpur
	returns link only
]]
p.pur = function(frame)
	local base = parseArgs(frame)
	if base.err then return base.err end
	local pos = base.provider.getPosition(base.chapter, base.verses)
	local f = base.provider.urlForm
	return '<small class="noprint" title="' .. base.title .. ' bei '
		.. base.provider.name .. '">[' .. f[1] .. base.link .. f[2]
		.. base.vl1 .. f[3] .. pos .. f[4] .. ' '
		.. base.version .. ']</small>'
end

local function posLabel(pos)
	local result = pos:gsub(':', ',')
	result = mw.ustring.gsub(result, '(%d)%f[f]', '%1&nbsp;') 
	return mw.ustring.gsub(result, '-', '–') 
end

--[[
	=> Vorlage:BB
	returns pos and link
]]
p.pos = function(frame)
	local base = parseArgs(frame)
	if base.err then return base.err end
	local pos = base.provider.getPosition(base.chapter, base.verses)
	local f = base.provider.urlForm
	return posLabel(pos) .. ' <small class="noprint" title="' .. base.title
		.. ' bei ' .. base.provider.name .. '">[' .. f[1] .. base.link .. f[2]
		.. base.vl1 .. f[3] .. pos .. f[4] .. ' '
		.. base.version .. ']</small>'
end

--[[
	=> Vorlage:B
	returns book, pos and link
]]
p.Bpos = function(frame)
	local base = parseArgs(frame)
	if base.err then return base.err end
	local pos = base.provider.getPosition(base.chapter, base.verses)
	local f = base.provider.urlForm
	local result = ''
	local noSelf = ' '
	if (	base.book.wp ~= mw.title.getCurrentTitle().text
		and	base.book.wp ~= mw.title.getCurrentTitle().prefixedText
		and not base.book.label:find('%[%[')) then
		result = '[[' .. base.book.wp .. '|'
		noSelf = ']] '
	end
	result = result .. base.book.label .. noSelf .. posLabel(pos)
	return result .. ' <small class="noprint" title="' .. base.title
		.. ' bei ' .. base.provider.name .. '">[' .. f[1] .. base.link
		.. f[2] .. base.vl1 .. f[3] .. pos .. f[4] .. ' '
		.. base.version .. ']</small>'
end

return p