Modul:Xanxank

Ji Wîkîpediya, ensîklopediya azad.
Belgekirina modulê[biafirîne]
p = {}

	-- ISO country codes with country name (1), chart link (2), abbreviated chart publisher (3), certification publisher link (4), abbreviated certification publisher (5), no. 1 list ID (6)
	countrytable = {
		["AUT"] = { "Awistirya", "Ö3 Austria Top 40", "Ö3", "IFPI Austria – Verband der Österreichischen Musikwirtschaft", "IFPI", "Österreich" },
		["ARG"] = { "Arjentîn", "Argentinien", "CAPIF", "Cámara Argentina de Productores de Fonogramas y Videogramas", "CAPIF", "Argentinien" },
		["AUS"] = { "Awistralya", "Xanxanka Stranên Awistralya", "ARIA", "Australian Recording Industry Association", "ARIA", "Australien" },
		["BEL"] = { "Belgiya", "Xanxanka Stranên Belgiya", "Ultratop", "Belgian Entertainment Association", "BEA", "Belgien" },
		["BGR"] = { "Bulgaristan", "Bulgarien", "BAMP", "Bulgarian Association of the Music Producers", "BAMP", "Bulgarien" },
		["BRA"] = { "Brazîl", "Brasilien", "PMB", "Pró-Música Brasil", "PMB" },
		["CAN"] = { "Kanada", "Xanxanka Stranên Kanada", "MC", "Music Canada", "MC", "Kanada" },
		["CHE"] = { "Swîsre", "Hitparadeya Swîsre", "IFPI", "IFPI Schweiz", "IFPI", "der Schweiz" },
		["CHL"] = { "Şîle", "Chile", "",  "IFPI Chile", "IFPI" },
		["COL"] = { "Kolumbiya", "Kolumbien", "",  "Asociación Colombiana de Productores de Fonogramas", "ASINCOL" },
		["CZE"] = { "Çekya", "Tschechien", "IFPI", "IFPI Tschechien", "IFPI", "Tschechien" },
		["DEU"] = { "Almanya", "Xanxanka Stranên Almanya", "GfK", "Bundesverband Musikindustrie", "BVMI", "Almanya" },
		["DNK"] = { "Danîmarka", "Hitlisten (dänische Musikcharts)", "IFPI/Nielsen", "IFPI Dänemark", "IFPI", "Dänemark" },
		["ECU"] = { "Ekwador", "Ecuador", "",  "Sociedad de Productores de Fonogramas", "SOPROFON" },
		["ESP"] = { "Spanya", "Xanxanka Stranên Spanya", "Promusicae", "Productores de Música de España", "Promusicae", "Spanien" },
		["EUR"] = { "Ewropa", "Ewropa", "",  "International Federation of the Phonographic Industry", "IFPI" },
		["FIN"] = { "Fînlenda", "Xanxanka Stranên Fînlenda", "IFPI", "Musiikkituottajat – IFPI Finland", "IFPI", "Finnland" },
		["FRA"] = { "Fransa", "Fransa", "SNEP", "Syndicat National de l’édition Phonographique", "SNEP", "Frankreich" },
		["GRC"] = { "Yewnanistan", "IFPI Griechenland#Musikcharts", "IFPI", "IFPI Griechenland", "IFPI", "Griechenland" },
		["HKG"] = { "Hongkong", "Hongkong", "",  "IFPI Hong Kong Group", "IFPI/HKRIA" },
		["HUN"] = { "Macaristan", "Ungarn", "MAHASZ", "Magyar Hanglemezkiadók Szövetsége", "MAHASZ", "Ungarn" },
		["HRV"] = { "Kroatya", "Kroatien", "HDU", "Hrvatska diskografska udruga", "HDU", "Kroatien" },
		["IDN"] = { "Endonezya", "Indonesien", "",  "Asosiasi Industri Rekaman Indonesia", "ASIRI" },
		["IND"] = { "Hindistan", "Indien", "",  "The Indian Music Industry", "IMI" },
		["IRL"] = { "Îrlenda", "Irische Musikcharts", "IRMA", "Irish Recorded Music Association", "IRMA", "Irland" },
		["ISL"] = { "Îslenda", "Island", "",  "IFPI Island", "IFPI" },
		["ITA"] = { "Îtalya", "Xanxanka Stranên Îtalî", "FIMI", "Federazione Industria Musicale Italiana", "FIMI", "Italien" },
		["JPN"] = { "Japonya", "Oricon#Oricon-Charts", "Oricon", "Recording Industry Association of Japan", "RIAJ", "Japan" },
		["KOR"] = { "Korêya Başûr", "Gaon Chart", "KMCA", "Korea Music Content Association", "KMCA", "Südkorea" },
		["LBN"] = { "Lubnan", "Libanon", "",  "IFPI Middle East Awards", "IFPI" },
		["LVA"] = { "Letland", "Lettland", "",  "Latvian Music Producers Association", "LaMPA" },
		["MEX"] = { "Meksîk", "Mexiko", "AMPROFON", "Asociación Mexicana de Productores de Fonogramas y Videogramas", "AMPROFON", "Mexiko" },
		["MYS"] = { "Malezya", "Malaysia", "RIM", "Recording Industry Association of Malaysia", "RIM" },
		["NLD"] = { "Holenda", "Xanxanka Stranên Holenda", "Media Markt / Dutch Charts", "Nederlandse Vereniging van Producenten en Importeurs van beeld- en geluidsdragers", "NVPI", "den Niederlanden" },
		["NOR"] = { "Norwêc", "Xanxanka Stranên Norwêc", "Nielsen", "IFPI Norwegen", "IFPI", "Norwegen" },
		["NZL"] = { "Nû Zelanda", "Neuseeländische Musikcharts", "RMNZ", "Recorded Music NZ", "RMNZ"; "Neuseeland" },
		["PER"] = { "Perû", "Peru", "",  "Unión Peruana de Productores Fonográficos", "UNIMPRO" },
		["PHL"] = { "Pîlîpîn", "Philippinen", "",  "Kapisanan ng Industriya ng Plaka ng Pilipinas", "PARI" },
		["POL"] = { "Polonya", "Związek Producentów Audio-Video#Musikcharts", "ZPAV", "Związek Producentów Audio-Video", "ZPAV", "Polen" },
		["PRT"] = { "Portûgal", "Associação Fonográfica Portuguesa#Musikcharts", "AFP", "Associação Fonográfica Portuguesa", "AFP", "Portugal" },
		["ROU"] = { "Romanya", "Rumänien", "",  "", "", "Rumänien" },
		["RUS"] = { "Rûsya", "Russland", "",  "National Federation of Phonograph Producers", "NFPF" },
		["SVK"] = { "Slowakya", "Slowakei", "IFPI", "IFPI Tschechien", "IFPI", "Slowakei" },
		["SWE"] = { "Swêd", "Xanxanka Stranên Swêd", "GLF", "IFPI Schweden", "IFPI", "Schweden" },
		["SGP"] = { "Sîngapûr", "Singapur", "RIAS", "Recording Industry Association (Singapore)", "RIAS" },
		["SKE"] = { "Slowakya", "Slowakei", "IFPI", "", "", "der Slowakei" },
		["THA"] = { "Tayland", "Thailand", "",  "Thai Entertainment Content Trade Association", "TECA" },
		["TUR"] = { "Tirkiye", "Tirkiye", "",  "Bağlantılı Hak Sahibi Fonogram Yapımcıları Meslek Birliği", "MÜ-YAP" },
		["TWN"] = { "Taywan", "Republik China (Taiwan)", "",  "Recording Industry Foundation in Taiwan", "RIT" },
		["GBR"] = { "Keyaniya Yekbûyî", "Xanxanka Stranên Brîtanî", "OCC", "British Phonographic Industry", "BPI", "den britischen Charts" },
		["USA"] = { "Dewletên Yekbûyî yên Amerîkayê", "Billboard (Magazin)#Billboard-Charts", "Billboard", "Recording Industry Association of America", "RIAA", "den USA" },
		["URY"] = { "Ûrûgûay", "Uruguay", "",  "Cámara Uruguaya del Disco", "CUD" },
		["VEN"] = { "Venezuela", "Venezuela", "",  "Association of Venezuelan Phonograph Producers", "APFV" },
		["ZAF"] = { "Afrîkaya Başûr", "Südafrika", "",  "The Recording Industry of South Africa", "RISA"},
		
		-- definierte Sonderfälle
		["EUR2"] = { "Ewropa", "Europa", "",  "Impala (Verband)#Impala Music Awards", "Impala" },
		["GCC"] = { "Golf-Kooperationsrat", "Golf-Kooperationsrat", "",  "IFPI Middle East Awards", "IFPI" },
		["BEF"] = { "Flandern", "Musikcharts in Belgien", "Ultratop", "Belgian Entertainment Association", "BEA", "Belgien" },
		["BEW"] = { "Wallonie", "Musikcharts in Belgien", "Ultratop", "Belgian Entertainment Association", "BEA", "Belgien" },
		["NLD-A"] = { "Holenda", "Dutch Charts", "Dutch Charts", "Nederlandse Vereniging van Producenten en Importeurs van beeld- en geluidsdragers", "NVPI", "den Niederlanden" },
		["NLD-S"] = { "Holenda", "Nederlandse Top 40", "Media Markt", "Nederlandse Vereniging van Producenten en Importeurs van beeld- en geluidsdragers", "NVPI", "den Niederlanden" },
		["USA-A"] = { "Dewletên Yekbûyî yên Amerîkayê", "Billboard 200", "Billboard", "Recording Industry Association of America", "RIAA", "den USA" },
		["USA-S"] = { "Dewletên Yekbûyî yên Amerîkayê", "Billboard Hot 100", "Billboard", "Recording Industry Association of America", "RIAA", "den USA" }
		}
		
	-- certification names in English (1) and German (2)
	certtable = {
		["Silber"] = {"silver", "Zîv"},
		["S"] = {"silver", "Zîv"},
		["Gold"] = {"gold", "Zêr"},
		["G"] = {"gold", "Zêr"},
		["Platin"] = {"platinum", "Platîn"},
		["P"] = {"platinum", "Platîn"},
		["Diamant"] = {"diamond", "Almast"},
		["D"] = {"diamond", "Almast"},
		["P+G"] = {"Platinum and gold", "Platîn + Zêr"},
		["G+P"] = {"Platinum and gold", "Platîn + Zêr"}
	}


-- Länderspalten für Charttabellen - country columns in chart table head
p.countryhead = function (frame, countries, rformat, year)
	
	local ret = ""
	for c = 1, #countries.countries do
		local country = countries.countries[c]
		local countryconv = frame:expandTemplate{ title = 'ISO3166-A3-Konversion', args = { country } }
		local countrycode = countrytable[countryconv] or countrytable[country]

		if countryconv == "NLD" then
			if countries.rformat == "Singles" then
				countrycode = countrytable["NLD-S"]
			else
				countrycode = countrytable["NLD-A"]
			end
		elseif countryconv == "USA" then
			if countries.rformat == "Singles" then
				countrycode = countrytable["USA-S"]
			else
				countrycode = countrytable["USA-A"]
			end
		end
		ret = ret .. "\n! style='width:52px;background-color:#FFEBAD;' data-sort-type='number' | "
		if not countrycode then
			ret = ret .. country
		else
			ret = ret .. "{{"
		-- country code for flag template
			if country == "BEF" then
				ret = ret .. "BE-VLG"
			elseif country == "BEW" then
				ret = ret .. "BE-WAL"
			else
				ret = ret .. countryconv
			end
		-- chart link
			ret = ret .. "|" .. countrycode[2] .. "|"
		-- displayed link text
			if country == "BEF" then
				ret = ret .. "BE<sup>F</sup>"
			elseif country == "BEW" then
				ret = ret .. "BE<sup>W</sup>"
			elseif countryconv == "BEL" and (tonumber(countries.year) or 0) > 1994 then
				ret = ret .. "BE<div style='display:none;'>[[Şablon:Xanxank/Xwedîkirin/Belgiya]]</div>"
			else
				ret = ret .. frame:expandTemplate{ title = 'ISO3166-A2-Konversion', args = { country } }
			end
			ret = ret .. "}}"
		end
	end
	
	return ret
end

-- Charttabelle - chart table
p.charttablehead = function (frame)
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local countries = {}
	local i = 0
	for k, v in ipairs (parameters) do
		v = mw.text.trim( v )
		if #v > 0 then
			i = i + 1
			countries[i] = v
		end
	end
	local source = parameters["Çavkanî"]
	local rformat = parameters.Cure
	local legend = parameters.Legende
	local sortable = parameters.sortierbar
	local extra = parameters.Extra
	local titleaddition = parameters.SernavErg
	local content = parameters.Naverok or ""
	
	local tablewidth = {
		["1"]  = { "250", "320" },
		["1e"] = { "245", "220", "175" },
		["2"]  = { "300", "320" },
		["2e"] = { "285", "220", "175" },
		["3"]  = { "350", "300" },
		["3e"] = { "315", "210", "160" },
		["4"]  = { "400", "270" },
		["4e"] = { "345", "200", "160" }
	}
	
	local width = "1"
	if tablewidth[parameters.Breite] then
		width = parameters.Breite
	end
	if extra then
		width = width .. "e"
	end
	
	local ret = "<templatestyles src='Şablon:Xanxank/styles.css' />"
	if legend then
		ret = ret .. "<span style='font-size:smaller;font-style:italic;'>Sal: Sala yekem helwesta xanxankê; Helwestên xanxankê: bi cîhkirina herî zêde û tevahî hefte yên mayîna xanxankê (…: hîn di xanxankê de tê dîtin); Daxuyanî: Xelat bi hejmarek yekîneyên firotinê ye.</span>"
	end
	ret = ret .. "\n{| class='wikitable"
	if sortable then
		ret = ret .. " sortable"
	end
	ret = ret .. " charts-zebragrey' style='text-align:center; background-color:#E1E9F3' \n|-"
	ret = ret .. "\n! style='width:25px;background-color:#FFEBAD;' rowspan='2' | Sal"
	ret = ret .. "\n! style='width:" .. tablewidth[width][1] .. "px;background-color:#FFEBAD;' rowspan='2'| Sernav"
	if titleaddition then
		ret = ret .. "<br /><span style='font-size:smaller;font-style:italic;'>" .. titleaddition .. "</span>"
	elseif rformat == "Yekane (Single)" then
		ret = ret .. "<br /><span style='font-size:smaller;font-style:italic;'>Albûm</span>"
	end
	ret = ret .. "\n! style='background-color:#FFEBAD;' colspan='" .. #countries .. "'|"
	if #countries > 1 then
		ret = ret .. " Helwesta Xanxankê"
	else
		ret = ret .. " Xanxank"
	end
	ret = ret .. (source or "<div style='display:none'>[[Şablon:Xanxank/Xwedîkirin/bêçavkanî]]</div>") .. "\n! style='width:" .. tablewidth[width][2] .. "px;background-color:#FFEBAD;' rowspan='2' class='unsortable' | Daxuyanî"
	if extra then
		ret = ret .. "\n! style='width:" .. tablewidth[width][3] .. "px;background-color:#FFEBAD;' rowspan='2' class='unsortable' |" .. extra
	end
	ret = ret .. "\n|-"
	
	-- country columns
	ret = ret .. p.countryhead( frame, {countries = countries, rformat = rformat, year = year } )
	
	ret = ret .. "\n|- \n" .. content .. "\n|- \n|}"

	return frame:preprocess (ret)
end



-- Chartauswertung - chart statistics
p.chartstatistics = function (frame)
	
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local countries = {}
	local i = 0
	for k, v in ipairs (parameters) do
		v = mw.text.trim( v )
		if #v > 0 then
			i = i + 1
			countries[i] = v
		end
	end
	if #countries > 8 then return "Too many countries" end
	local rformat = parameters.Art
	local comment = parameters.Anmerkung
	local istable = parameters.Tabelle
	local ret = nil
	
	if istable then
		ret = "{| class='wikitable charts-zebragrey2' style='text-align:center;' \n |- \n ! style='width:200px; background-color:#FFEBAD;' |"
		-- country columns
		ret = ret .. p.countryhead( frame, {countries = countries, rformat = rformat } )
		ret = ret .. "\n|-"
	else
		ret = "|- class='sortbottom charts-redstats'\n| rowspan='3'|"
	end
	
	ret = ret .. "\n| style='text-align:left;'|"
	if rformat then 
		ret = ret .. "Hejmara-yek-" .. rformat
	else 
		ret = ret .. "Hejmara yek"
	end
	for c = 1, #countries do
		local n = "NR1_" .. countries[c]
		local No1 = parameters[n]
		if No1 == "" or No1 == nil then
			ret = ret .. "\n| " .. "&mdash;"
		else
			ret = ret .. "\n| " .. No1
		end
	end
	
	if not istable then
		ret = ret .. "\n| rowspan='3' colspan='2' style='text-align:left; font-size:smaller;' |"
		if comment then
			ret = ret .. comment
		end
	end
	
	ret = ret .. "\n|- "
	if not istable then
		ret = ret .. "class='sortbottom charts-redstats' " 
	end
	ret = ret .. "\n| style='text-align:left;'|"
	if rformat then
		ret = ret .. "Top-10-" .. rformat
	else
		ret = ret .. "li ser Top 10'an"
	end
	for c = 1, #countries do
		local t = "T10_" .. countries[c]
		local Top10 = parameters[t]
		if Top10 == "" or Top10 == nil then
			ret = ret .. "\n| " .. "&mdash;"
		else
			ret = ret .. "\n| " .. Top10
		end
	end
	
	ret = ret .. "\n|- "
	if istable then
		ret = ret .. "style='background:#FBF8D6; font-weight:bold;'"
	else
		ret = ret .. "class='sortbottom charts-redstats'"
	end
	ret = ret .. "\n| style='text-align:left;'|" .. (rformat or "") .. " di nav Xanxankê"
	for c = 1, #countries do
		local g = "INSG_" .. countries[c]
		local Total = parameters[g]
		if Total == "" or Total == nil then
			ret = ret .. "\n| " .. "&mdash;"
		else
			ret = ret .. "\n| " .. Total
		end
	end
	
	if istable then
		ret = ret .. "\n|}"
	end
	
	return frame:preprocess (ret)
end



-- Charteintrag - chart table entry
p.charttablerow = function (frame)

	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end

	local countries = {}
	local i = 0
	for k, v in ipairs (parameters) do
		v = mw.text.trim( v )
		if #v > 0 then
			i = i + 1
			countries[i] = v
		end
	end
	local year = parameters.Sal
	local colour = parameters.Farbe
	
	local temporary = "<div style='display:none'>[[Şablon:Xanxank/Xwedîkirin/demekî"
	if tonumber(year) then
		if tonumber(year) > 2009 then
			temporary = temporary .. "/" .. year
		end
	end
	temporary = temporary .. "]]</div>"
	
	-- There may be "Sernav" instead of "Sernav1"
	if parameters["Sernav"] then
		parameters["Reng1"] = parameters["Reng"]
		parameters["Sernav1"] = parameters["Sernav"]
		parameters["Albûm1"] = parameters["Albûm"]
		parameters["SernavErg1"] = parameters["SernavErg"]
		for c = 1, #countries do
			local p = "Helwest_" .. countries[c]
			local p1 = "Helwest_" .. countries[c] .. "1"
			parameters[p1] = parameters[p]
			local w = "Hefte_" .. countries[c]
			local w1 = "Hefte_" .. countries[c] .. "1"
			parameters[w1] = parameters[w]
			local m = "Mehe_" .. countries[c]
			local m1 = "Mehe_" .. countries[c] .. "1"
			parameters[m1] = parameters[m]
			local y = "Sal_" .. countries[c]
			local y1 = "Sal_" .. countries[c] .. "1"
			parameters[y1] = parameters[y]
			local s = "Derizandin_" .. countries[c]
			local s1 = "Derizandin_" .. countries[c] .. "1"
			parameters[s1] = parameters[s]
			local z = "Rêzik_" .. countries[c]
			local z1 = "Rêzik_" .. countries[c] .. "1"
			parameters[z1] = parameters[z]
		end
		parameters["Daxuyanî1"] = parameters["Daxuyanî"]
		parameters["Bêhtir1"] = parameters["Bêhtir"]
		parameters["Bêhtir Rêzik1"] = parameters["Bêhtir Rêzik"]
	end
	local rows = 0
	repeat
		rows = rows + 1
		local title = "Sernav" .. rows
	until not parameters[title]
	rows = rows - 1
	
	if rows == 0 then return "Add some rows" end
	if #countries > 8 then return "Too many countries" end
	
	local ret = "|-" 
	-- fallback for row colours, overwriting CSS zebra style (first row)
	if colour == "1" then
		ret = ret .. " style='background:#eeeeee;'"
	elseif colour == "0" then
		ret = ret .. " style='background:#e1e9f3;'"
	end
	ret = ret .. "\n | rowspan='" .. rows .. "' style='background-color:#f0f0ff;' | " .. (year or "")
	
	if year then
		if not string.match (year, "^%d%d%d%d$") then
			ret = ret .. "<div style='display:none'>[[Şablon:Xanxank/Xwedîkirin/Sal]]</div>"
		end
	end
	
	for row = 1, rows do
		local t = "Sernav" .. row
		local title = parameters[t]
		local a = "Albûm" .. row
		local album = parameters[a]
		local ta = "SernavErg" .. row
		local titleaddition = parameters[ta]
		local co = "Reng" .. row
		local rowcolour = parameters[co]
		if row > 1 then
			ret = ret .. "\n|-"
		-- individual row colours, overwriting everything
			if rowcolour == "1" then
				ret = ret .. " style='background:#eeeeee;'"
				else
					if rowcolour == "0" then
						ret = ret .. " style='background:#e1e9f3;'"
						else
		-- fallback for row colours, overwriting CSS zebra style (other rows)
					--check if even
							if row % 2 == 0 then
								if colour == "0" then
									ret = ret .. " style='background:#eeeeee;'"
								elseif colour == "1" then
									ret = ret .. " style='background:#e1e9f3;'"
								end
							-- if odd
							else
								if colour == "0" then 
									ret = ret .. " style='background:#e1e9f3;'"
								elseif colour == "1" then
									ret = ret .. " style='background:#eeeeee;'"
								end
							end
						end
					end
				end
		ret = ret .. "\n| style='text-align:left;' | " .. title .. "<br><span style='font-style:italic;font-size:smaller;'>" .. (album or titleaddition or "") .. "</span>"
		
		for c = 1, #countries do
			local p = "Helwest_" .. countries[c] .. row
			local position = parameters[p]
			if position ~= "n" then
				local w = "Hefte_" .. countries[c] .. row
				local weeks = parameters[w]
				local m = "Mehe_" .. countries[c] .. row
				local months = parameters[m]
				local y = "Sal_" .. countries[c] .. row
				local year1 = parameters[y]
				local s = "Derizandin_" .. countries[c] .. row
				if parameters[s] and #parameters[s] == 0 then parameters[s] = nil end
				local z = "Rêzik_" .. countries[c] .. row
				if parameters[z] and #parameters[z] == 0 then parameters[z] = nil end
				ret = ret .. "\n|"
				if parameters[s] then
					ret = ret .. " colspan='" .. parameters[s] .. "'"
				end
				if parameters[z] then
					ret = ret .. " rowspan='" .. parameters[z] .. "'"
				end
				if parameters[s] or parameters[z] then
					ret = ret .. " | "
				end
				if position then
					if string.match(position, "^%[%[Lîste") then
						ret = ret .. "<div style='display:none;'>[[Şablon:Xanxank/Xwedîkirin/Helwest]]</div>"
					end					
				-- create automatic links to lists of number-one hits in selected countries
					if position == "1" or string.match(position, "^1%D") then
						local country = countries[c]
						local countryconv = frame:expandTemplate{ title = 'ISO3166-A3-Konversion', args = { country } }
						local countrycode = countrytable[countryconv] or countrytable[country]

						if countrycode then
							if countrycode[6] then
								position = "[[Lîsteya Hejmara-yek-Hit li " .. countrycode[6] .. " (" .. (year1 or year or "") .. ")|<b>1</b>]]" .. (string.match(position, "1(.*)") or "")
							else
								position = "<b>1</b>" .. (string.match(position, "1(.*)") or "")
							end
						else
							position = "<b>1</b>" .. (string.match(position, "1(.*)") or "")
						end
					end
					if position == "" then
						ret = ret .. "<span style='display:none;'>300!</span>&mdash;"
					else
						if weeks then
							if weeks == "n" then
								ret = ret .. position
							else
								if weeks == "" then
									ret = ret .. position .. "<br><span style='font-size:smaller;'>(&hellip; Hefte)</span>" .. temporary
								else
									ret = ret .. position .. "<br><span style='font-size:smaller;'>(" .. weeks .. " Hefte)</span>"
								end
							end
						else
							if months then
								if months == "n" then
									ret = ret .. position
								else
									if months == "" then
										ret = ret .. position .. "<br><span style='font-size:smaller;'>(&hellip; Mehe)</span>" .. temporary
									else
										ret = ret .. position .. "<br><span style='font-size:smaller;'>(" .. months .. " Mehe)</span>"
									end
								end
							else
								if position then
									ret = ret .. position .. "<br><span style='font-size:smaller;'>(&hellip; Hefte)</span>" .. temporary
								end
							end
						end
					end
				else
					ret = ret .. "<span style='display:none;'>300!</span>&mdash;"
				end
			end
		end
		local com = "Daxuyanî" .. row
		local comment = parameters[com]
		ret = ret .. "\n| style='text-align:left;' |"
		if comment then
			ret = ret .. "<div style='font-size:smaller;'>\n" .. comment .. "</div>"
		end
		local x = "Bêhtir" .. row
		local extra = parameters[x]
		local zx = "Bêhtir Rêzik" .. row
		if extra then
			if parameters[zx] then
				ret = ret .. "\n| rowspan='" .. parameters[zx] .. "' style='text-align:left;' | " .. extra
			else
				ret = ret .. "\n| style='text-align:left;' | " .. (extra or "")
			end
		end
		
	end
	
	return ret
end


-- Chartplatzierungen - chart positions table
p.chartposhead = function (frame)
	
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local entry = {}
	for k, v in ipairs (parameters) do
		entry [k] = v
	end
	local rows = 0
	repeat
		rows = rows + 1
		local entry = "" .. rows
	until not parameters[entry]
	rows = rows - 1
	
	local ret = "{| class='wikitable'"
	local title = parameters.Titel
	local year = parameters.Jahr
	
	if title then
		ret = ret .. "\n|+ " .. title
	end
	ret = ret .. "\n|- \n! style='width:250px;background-color:#FFEBAD;'| Xanxank"
	if year then
		ret = ret .. " (" .. year .. ") \n! style='width:90px;background-color:#FFEBAD;' | Helwest"
	else
		ret = ret .. "\n! style='width:150px;background-color:#FFEBAD;' | Helwesta herî zêde \n! style='width:90px;background-color:#FFEBAD;' | Hefte"
	end
	-- single rows
	ret = ret .. "\n|- style='background:#E1E9F3;'"
	for row = 1, rows do
		ret = ret .. "\n" .. entry[row]
	-- even rows should have different colour from odd rows
		if row % 2 == 1 then
			ret = ret .. "\n|- style='background:#EEEEEE;'"
		else
			ret = ret .. "\n|- style='background:#E1E9F3;'"
		end
	end
	ret = ret .. "\n|}"
	
	return ret

end

-- Charts - chart positions table entry
p.chartposrow = function (frame)

	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local countryraw = parameters[1]
	local country = string.match (parameters[1], "(.*)%s%(.*%)") or countryraw
	local brackets = string.match (parameters[1], ".*%s(%(.*%))")
	local countryconv = frame:expandTemplate{ title = 'ISO3166-A3-Konversion', args = { country } }
	local countrycode = countrytable[countryconv] or countrytable[country]
	local position = parameters[2]
	local weeks = parameters[3]
	local ref = parameters.Q
	local year = parameters.Jahr
	
	local ret = "| "
	
	-- template code for country display
	local countrydisplay = "{{"
	if countrycode then
		if country == "BEF" then
			countrydisplay = countrydisplay .. "BE-VLG"
		elseif country == "BEW" then
			countrydisplay = countrydisplay .. "BE-WAL"
		elseif string.match (country, "^NLD" ) then
			countrydisplay = countrydisplay .. "NLD"
		elseif string.match (country, "^USA" ) then
			countrydisplay = countrydisplay .. "USA"
		else
			countrydisplay = countrydisplay .. countryconv
		end
		countrydisplay = countrydisplay .. "|" .. countrycode[2] .. "|" .. countrycode[1] .. " (" .. countrycode[3] .. ")}}"
	else
		countrydisplay = countrydisplay .. country .. "}}"
	end
	
	if brackets then
		if countrycode then
			countrydisplay = countrydisplay:gsub ("%(.*%)", brackets )
		else
			countrydisplay = countrydisplay:gsub ("}}", " " .. brackets .. "}}")
		end
	end
	
	ret = ret .. countrydisplay
	
	-- sources
	ret = ret .. (ref or "")
	
	-- chart position
	local numberone = nil
	if countrycode then
		numberone = countrycode[6]
	end
	local numberonelink = nil
	if numberone then
		numberonelink = "Lîsteya Hejmara-yek-Hit li " .. numberone
		if year then
			numberonelink = numberonelink .. " (" .. year .. ")"
		end
	end
	ret = ret .. "\n| style='text-align:center;' |"
	if position then
		if position == "1" or string.match(position, "^1%D") then
			if numberonelink then
				position = "<b>[[" .. numberonelink .. "|1]]</b>" .. (string.match(position, "1(.*)") or "")
			else
				position = "<b>1</b>" .. (string.match(position, "1(.*)") or "")
			end
		end
		ret = ret .. position
	end
	
	-- weeks on chart
	if weeks then
		if weeks == "" then weeks = "&hellip;" .. "<div style='display:none'>[[Vorlage:Chartplatzierungen/Wartung/vorläufig]]</div>" end
		ret = ret .. "\n| style='text-align:center;' |" .. weeks
	end
	
	return frame:preprocess (ret)
end


-- Infobox Chartplatzierungen - chart positions infobox
p.chartinfobox = function (frame)

	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end -- always [?]
	
	local file = parameters.Bild
	local caption = parameters.Bildbeschreibung
	local temporary = parameters["vorläufige Chartplatzierung"]
	local temporaryweeks = nil
	local albums = parameters.Alben
	local eps = parameters.EPs
	local singles = parameters.Singles
	local dvds = parameters.DVDs
	local rformats = { albums, eps, singles, dvds }
	local titles = {"Alben", "EPs", "Singles", "DVDs"}
	local refalbums = parameters["Quellen Alben"]
	local refeps = parameters["Quellen EPs"]
	local refsingles = parameters["Quellen Singles"]
	local refdvds = parameters["Quellen DVDs"]
	local refs = { refalbums, refeps, refsingles, refdvds }
	local source = parameters.Quellen
	
	for temp = 1, 4 do
		if rformats[temp] then
			if string.match (rformats[temp], "%(&hellip;" ) then
				temporaryweeks = true
			end
		end
	end
	
	local ret = "<div>\n{| class='float-right' style='background-color:#FFFFFF; width:208px; border:1px solid #DDD;' \n|-"
	if file then
		if file ~= "" then
			ret = ret .. "\n| [[Wêne:" .. file .. "|200px|" .. (caption or mw.title.getCurrentTitle().text) .. "]]"
			if caption then
				if caption ~= "" then
					ret = ret .. "\n|- \n| style='text-align:center; font-size:smaller;' | " .. caption
				end
			end
		end
	end
	ret = ret .. "\n|- \n| style='background-color:#F3F3F3; text-align:center;' | <span style='font-size:20px; font-stretch:condensed'>Helwesta Xanxankê</span>"
	if temporaryweeks then
		ret = ret .. "<br /><span style='font-size:12px; font-stretch:condensed;'>(ji bo demekî)</span>"
	end
	ret = ret .. "<br /><span style='font-size:smaller;'>[[Wîkîpediya:Şablona Xanxankê|Daxuyaniya Daneyan]]</span>"
	
	for section = 1, 4 do
		if rformats[section] then
			if rformats[section] ~= "" then
				ret = ret .. "\n|- style='background:#EAECF0;' \n| style='padding:0 .3em;' | <span style='font-size:larger; font-weight:bold;'>" .. titles[section] .. "</span>" .. (refs[section] or "")
				ret = ret .. "\n|- \n| style='padding:0 .3em .5em .3em;' | \n{| style='border-collapse:collapse;width:100%;' \n" .. rformats[section] .. "\n|}"
			end
		end
	end
	
	ret = ret .. "\n|}</div>"
	
	if source then
		ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Quellen-Parameter]]</div>"
	elseif not refalbums and not refsingles and not refeps and not refdvds then
		ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/ohne Quellen]]</div>"
	end
	if temporary then
		ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/vorläufige Chartplatzierung]]</div>"
	end
	
	return ret
	
end


-- Infobox Chartplatzierungen/Werk - chart positions infobox entry
p.chartinfoboxentry = function (frame)
	
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local templatename = frame:getParent():getTitle()
	local rformat = string.match (templatename, "Şablon:(%a*)")
	local rows = {}
	local i = 0
	for k, v in ipairs (parameters) do
		local chartlinksub = { ["US"] = { "Billboard Hot 100", "Billboard 200" }, ["NL"] = { "Nederlandse Top 40", "Dutch Charts" } }
		local index = nil
		if rformat == "Single" then index = 1 else index = 2 end
		v = string.gsub (v, "Billboard %(Magazin%)#Billboard%-Charts", chartlinksub["US"][index])
		v = string.gsub (v, "Niederländische Musikcharts", chartlinksub["NL"][index])
		
		if #v > 0 then
			i = i + 1
			rows[i] = v
		end
	end
	
	local ret = "\n|- \n| colspan='6' style='font-size:95%;font-weight:bold;' |" .. (rows[1] or "")
	
	for row = 2, #rows do
		ret = ret .. "\n|- style='background:#F3F3F3;' \n" .. mw.text.trim( rows[row] )
	end
	
	return ret
end


-- Charts - chart positions infobox row
p.chartinfoboxrow = function (frame)
	
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local country = string.gsub (parameters[1], "(BE)<sup>(%a*)</sup>", "%1%2")
	local position = parameters[2]
	if position then
		position = mw.text.trim (position)
	end
	local entrydate = parameters[3]
	if entrydate then
		entrydate = mw.text.trim (entrydate)
	end
	local weeks = parameters[4]
	if weeks then
		weeks = mw.text.trim (weeks)
	end
	local ref = parameters[5]
	local year = parameters.Jahr or string.match (entrydate, "(%d%d%d%d)$")
	
	local countryconv = frame:expandTemplate{ title = 'ISO3166-A3-Konversion', args = { country } }
	local countrycode = countrytable[countryconv] or countrytable[country]
	
	local chartlink = nil
	local numberone = nil
	if countrycode then
		chartlink = countrycode[2]
		numberone = countrycode[6]
	end
	
	local numberonelink = nil
	if numberone then
		numberonelink = "Liste der Nummer-eins-Hits in " .. numberone
		if year then
			numberonelink = numberonelink .. " (" .. year .. ")"
		end
	end
	
	local ret = "| style='width:5%; background-color:white;' | &nbsp;"
	ret = ret .. "\n| style='width:10%; font-size:95%;' | "
	if chartlink then
		local countrydisplay = 0
		if country == "BEF" then
			countrydisplay = "BE<sup>F</sup>"
		elseif country == "BEW" then
			countrydisplay = "BE<sup>W</sup>"
		elseif string.match (country, "^NL" ) then
			countrydisplay = "NL"
		elseif string.match (country, "^US" ) then
			countrydisplay = "US"
		else
			countrydisplay = country
		end
		ret = ret .. "[[" .. chartlink .. "|" .. countrydisplay .. "]]"
	else
		ret = ret .. (country or "")
	end
	if countryconv == "BEL" and (tonumber(year) or 0) > 1994 then
		ret = ret .. "<div style='display:none;'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Belgien]]</div>"
	end
	ret = ret .. "\n| style='width:20%; font-size:95%; font-weight:bold; text-align:center;' | "
	if position then
		if string.match(position, "^%[%[Liste") then
			ret = ret .. "<div style='display:none;'>[[Vorlage:Infobox Chartplatzierungen/Wartung/POS verlinkt]]</div>"
		end
		if position == "1" or string.match(position, "^1%D") then
			if numberonelink then
				position = "[[" .. numberonelink .. "|1]]" .. (string.match(position, "1(.*)") or "")
				if not parameters.Jahr then
					position = position .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/NR1-Link]]</div>"
				end
			end
		end
		ret = ret .. position
	end
	ret = ret .. "\n| style='width:30%; font-size:smaller;' | " .. (entrydate or "")
	ret = ret .. "\n| style='width:25%; text-align:right; padding-left:5px; font-size:smaller;' | "
	if weeks then
		if weeks == "" or weeks == "…" or weeks == "..." then
			weeks = "&hellip;<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/vorläufig"
			if year then
				if tonumber(year) > 2009 then
					weeks = weeks .. "/" .. year
				end
			end
			weeks = weeks .. "]]</div>"
			if weeks == "..." then
				weeks = weeks .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Punkte]]</div>"
			end
		end
		if string.match (weeks, "Mt") then
			ret = ret .. "(" .. weeks .. ")"
		else
		    ret = ret .. "(" .. weeks .. "&nbsp;Wo.)"
		end
	end
	ret = ret .. "\n| style='width:10%; font-size:smaller;' | " .. (ref or "")
	
	if string.match (parameters[1], "%a*<sup>%a*</sup>") then
		ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Sup]]</div>"
	elseif string.match (country, "[^%a%s]") then
		ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Land falsch]]</div>"
	elseif not countrycode then
		if country ~= "DDR" then
			ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Land unbekannt]]</div>"
		end
	end
	if #entrydate < 4 or string.match (entrydate, "[^%d%./]") then
		ret = ret .. "<div style='display:none'>[[Vorlage:Infobox Chartplatzierungen/Wartung/Datum falsch]]</div>"
	end
	
	return ret
end

-- Wechsel zwischen Chartplatzierungen-Zeile und Chartbox-Zeile - switch between chart positions table row and infobox row
p.chartrows = function (frame)
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	if parameters.Q then
		return p.chartposrow(frame)
	else
		return p.chartinfoboxrow(frame)
	end
	
end


-- AfM-Tabelle - table for certifications
p.certificationtable = function (frame)
	
	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local entry = {}
	for k, v in ipairs (parameters) do
		entry [k] = v
	end
	local rows = 0
	repeat
		rows = rows + 1
		local entry = "" .. rows
	until not parameters[entry]
	rows = rows - 1
	
	local ret = frame:preprocess( "<templatestyles src='Vorlage:Charttabelle/styles.css' />" )
	local statistics = parameters.Statistik
	local main = parameters.Hauptartikel
	local note = parameters.Hinweis
	local source = parameters.Q
	local nosilver = parameters.S
	local nodiamond = parameters.D
	
	local pagename = mw.title.getCurrentTitle().text
	if statistics and not note and not main and not string.match (pagename, "/Auszeichnungen für Musikverkäufe") then
		local pagenameroot = string.match ( pagename, "(.+)/Diskografie" ) or pagename
		local certifications = pagenameroot .. "/Auszeichnungen für Musikverkäufe"
		if mw.title.new( certifications ).exists == false then
			ret = ret .. "\n<span style='font-style:italic;font-size:smaller;'>Anmerkung: Auszeichnungen in Ländern aus den Charttabellen sind in ebendiesen zu finden.</span>"
		end
	end
	ret = ret .. "\n{| class='wikitable"
	if statistics then
		ret = ret .. " sortable charts-zebragrey'"
	else
		ret = ret .. " charts-zebragrey2'"
	end
	ret = ret .. "\n|- \n! style='width:250px;background-color:#FFEBAD;'| Welat/Herêm \n!"
	if statistics then
		if not nosilver then
			ret = ret .. "style='background-color:#FFEBAD;' | [[Wêne:Silver record icon.svg|15px]] Zîv !! "
		end
		ret = ret .. "style='background-color:#FFEBAD;' | [[Wêne:Gold record icon.svg|15px]] Zêr !! "
		ret = ret .. "style='background-color:#FFEBAD;' | [[Wêne:Platinum record icon.svg|15px]] Platîn"
		if not nodiamond then
			ret = ret .. " !! style='background-color:#FFEBAD;' | [[Wêne:Diamond record icon.svg|15px]] Almast"
		end
	else
		ret = ret .. "style='width:150px;background-color:#FFEBAD;' | Xelat" .. (source or "")
	end
	ret = ret .. "\n! style='width:90px;background-color:#FFEBAD;' data-sort-type='number' | Firotin"
	if statistics then
		ret = ret .. "\n ! class='unsortable' style='background-color:#FFEBAD;' | Çavkanî"
	end
	-- single rows
	ret = ret .. "\n|-"
	for row = 1, rows do
		ret = ret .. "\n" .. entry[row] .. "\n|-"
	end
	
	local silver = parameters.GesS
	local gold = parameters.GesG
	local platinum = parameters.GesP
	local diamond = parameters.GesD
	local number = parameters.GesZ
	
	ret = ret .. "\n|-"
	if statistics then
		ret = ret .. "style='background:#FBF8D6;' class='sortbottom' \n| <b>Tevahî</b>"
		if not nosilver then
			ret = ret .. "\n| style='text-align:center;' | <b>" .. (silver or "&mdash;") .. "</b>"
		end
		ret = ret .. "\n| style='text-align:center;' | <b>" .. (gold or "&mdash;") .. "</b>"
		ret = ret .. "\n| style='text-align:center;' | <b>" .. (platinum or "&mdash;") .. "</b>"
		if not nodiamond then
			ret = ret .. "\n| style='text-align:center;' | <b>" .. (diamond or "&mdash;") .. "</b>"
		end
		ret = ret .. "\n| colspan='2' |"
	else
		if number then
			ret = ret .. "style='background:#FBF8D6;' \n| <i>Tevahî</i> \n| style='text-align:center; font-style:italic;' |"
			if silver or gold or platinum or diamond then
				if silver then
					ret = ret .. "[[Wêne:Silver record icon.svg|15px]] " .. silver .. "× Zîv<br />"
				end
				if gold then
					ret = ret .. "[[Wêne:Gold record icon.svg|15px]] " .. gold .. "× Zêr<br />"
				end
				if platinum then
					ret = ret .. "[[Wêne:Platinum record icon.svg|15px]] " .. platinum .. "× Platîn<br />"
				end
				if diamond then
					ret = ret .. "[[Wêne:Diamond record icon.svg|15px]] " .. diamond .. "× Almast<br />"
				end
			else
				ret = ret .. "&mdash;"
			end
			ret = ret .. "\n| style='text-align:right; font-style:italic;' | <b>" .. number .. "</b>"
		end
	end
	ret = ret .. "\n|}"	
	if main then
		ret = ret .. "\n<span style='font-style:italic; font-size:smaller;'>Gotara Sereke: [[" .. main .. "]]</span>"
	end
		
return ret

end


-- AfM2 - certification table rows
p.certificationtablerow = function (frame)

	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local numbers = { "", "Double", "Triple", "Quadruple", "Quintuple", "Sextuple", "Septuple", "Octuple", "Nonuple" }

	local silver = parameters.S
	local gold = parameters.G
	local platinum = parameters.P
	local diamond = parameters.D
	local source = parameters.Q
	
	local country = parameters[1]
	local certification = parameters[2]
	local number = parameters[3]
	local sum = parameters[4]
	
	local ret = "| "
	local countrycode = nil
	local countryconv = frame:expandTemplate{ title = 'ISO3166-A3-Konversion', args = { country } }
	if countrytable[country] then
		countrycode = country
	else
		countrycode = countryconv
	end
	
	if countrytable[countrycode] then
		ret = ret .. "{{"
		if countrycode == "EUR2" then
			ret = ret .. "EUR"
		else
			ret = ret .. countrycode
		end
		ret = ret .. "|" .. countrytable[countrycode][4] .. "|" .. countrytable[countrycode][1] .. " (" .. countrytable[countrycode][5] .. ")}}"
	else
		ret = ret .. country
	end
	
	if silver or gold or platinum or diamond then
		local sum2 = parameters[2]
		if silver ~= "n" then
			ret = ret .. "\n| style='text-align:center;' |" .. (silver or "<span style='display:none;'>0!</span>&mdash;")
		end
		ret = ret .. "\n| style='text-align:center;' |" .. (gold or "<span style='display:none;'>0!</span>&mdash;")
		ret = ret .. "\n| style='text-align:center;' |" .. (platinum or "<span style='display:none;'>0!</span>&mdash;")
		if diamond ~= "n" then
			ret = ret .. "\n| style='text-align:center;' |" .. (diamond or "<span style='display:none;'>0!</span>&mdash;")
		end
		ret = ret .. "\n| style='text-align:right;' |" .. (sum2 or "<span style='display:none;'>0!</span>&mdash;")
		ret = ret .. "\n| " .. (source or "")
	else
		ret = ret .. (source or "") .. "\n| style='text-align:center;' | "
		if certification == "" or certification == "-" or certification == "—" then
			ret = ret .. "&mdash;"
		elseif number == "" or number == "-" or number == "—" then
			ret = ret .. certification or ""
		elseif certification == "D+P" or certification == "P+D" then
			ret = ret .. "[[Wêne:Diamond record icon.svg|15px]][[Wêne:Decuple platinum record icon.svg|15px]]&nbsp;" .. number .. "×&nbsp;Platîn"
		else
			-- explicitely avoiding links to non-existing files
			if (certification == "S" or certification == "Zîv") and (tonumber(number) == 2 or tonumber(number) > 6) then
				ret = ret .. "[[Wêne:Silver record icon.svg|15px]]&nbsp;"
			else
				if (certification == "D" or certification == "Almast") and tonumber(number) > 7 then
					ret = ret .. "[[Wêne:Diamond record icon.svg|15px]]&nbsp;"
				else
				-- creating a valid file link in all cases images exist on Commons
					ret = ret .. "[[Wêne:"
					if tonumber(number) > 1 then
						if tonumber(number) > 9 then
							ret = ret .. "Decuple "
						else
							ret = ret .. numbers[tonumber(number)] .. " "
						end
					end
					if certtable[certification][1] then
						ret = ret .. certtable[certification][1] .. " "
					end
					ret = ret .. "record icon.svg|15px]]&nbsp;"
				end
			end
			if tonumber(number) > 1 then
				ret = ret .. number .. "×&nbsp;"
			end
			if certtable[certification][2] then
				ret = ret .. certtable[certification][2]
			else
				ret = ret .. certification
			end
		end
		ret = ret .. "\n| style='text-align:right;' | " .. (sum or "")
		
	end

return frame:preprocess (ret)

end


-- AfM - inline certification
p.certification = function (frame)

	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local certification = parameters[1]
	local number = parameters[2]
	local sum = parameters[3]
	local numbers = { "", "Double", "Triple", "Quadruple", "Quintuple", "Sextuple", "Septuple", "Octuple", "Nonuple" }
	
	local ret = ""
	if certification == "D+P" or certification == "P+D" then
		ret = ret .. "[[Wêne:Diamond record icon.svg|15px]][[Wêne:Decuple platinum record icon.svg|15px]]&nbsp;" .. number .. "×&nbsp;Platîn"
	elseif certification == "G+P" or certification == "P+G" then
		ret = ret .. "[[Wêne:" .. certtable[certification][1] .. " record icon.svg|15px]]&nbsp;" .. certtable[certification][2]
	else
		ret = ret .. "[[Wêne:"
			if tonumber(number) > 1 then
				if tonumber(number) > 9 then
					ret = ret .. "Decuple "
				else
					ret = ret .. numbers[tonumber(number)] .. " "
				end
			end
			if certtable[certification] then
				ret = ret .. certtable[certification][1] .. " "
			end
			ret = ret .. "record icon.svg|15px]]&nbsp;"
			if tonumber(number) > 1 then
				ret = ret .. number .. "×&nbsp;"
			end
			if certtable[certification] then
				ret = ret .. certtable[certification][2]
			else
				ret = ret .. certification
			end
	end
	if sum then
		ret = ret .. " (" .. sum .."+)"
	end
	
	return frame:preprocess (ret)
	
end


-- Wechsel zwischen AfM/AfM2 - switch between certificationtablerow and certification
p.certifications = function (frame)

	local parameters = frame.args
	if not parameters[1] then parameters = mw.getCurrentFrame():getParent().args end
	
	local ID = parameters[1]
	
	if certtable[ID] then
		return p.certification(frame)
	else
		return p.certificationtablerow(frame)
	end
	
end


return p