Modul:Vorlage:Infobox PKW-Modell

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Die Dokumentation für dieses Modul kann unter Modul:Vorlage:Infobox PKW-Modell/Doku erstellt werden

--[[  
Modul für Hilfsfunktionen für Vorlage:Infobox PKW-Modell
]]
local p = { }

function p.getCategoryForMarke(frame)
--[[  
	Kategorie zur Marke ermitteln (falls vorhanden)
	Parameter: 
	*	WikiMarkup zur Marke
	*	Modell
]]
	local marke = p._extractLinkTarget(frame.args[1])
	local modell = frame.args[2] or ""
	local wiki_markup_cat = ""
	-- Tabelle zur Übersetzung des Linkziels für die Marke (Lemma des entspr. Artikels) in die Kategorie
	local tab_cat = {
		 ["AC Cars"] = "AC Cars"
		,["Acura"] = "Acura"
		,["Adam Motor Company"] = "Adam Motor Company"	
		,["Adlerwerke"] = "Adlerwerke"
		,["Alfa Romeo"] = "Alfa-Romeo-Automobil"
		,["Allard"] = "Allard"
		,["Alpina Burkard Bovensiepen"] = "Alpina-Automobil"
		,["Alpine (Automobilhersteller)"] = "Alpine-Rennwagen"
		,["American Motors Corporation"] = "AMC-Automobil"
		,["Amilcar"] = "Amilcar-Automobil"
		,["Armstrong Siddeley"] = "Armstrong-Siddeley-Pkw"
		,["Aston Martin"] = "Aston-Martin-Automobil"
		,["Audi"] = "Audi-Automobil"
		,["Austin Motor Company"] = "Austin-Automobil"
		,["Austin-Healey"] = "Austin Motor Company"
		,["Autobianchi"] = "Autobianchi"
		,["AwtoWAS"] = "AwtoWAS"
		,["Bedford (Fahrzeughersteller)"] = "Bedford (Fahrzeughersteller)"
	    ,["Baojun"] = "Baojun"
		,["Beijing (Automarke)"] = "Beijing (Automarke)"
		,["Bentley"] = "Bentley"
		,["Benz & Cie."] = "Benz-Automobil"
		,["Berkeley Cars"] = "Berkeley Cars"
		,["Bestune"] = "Bestune"
		,["Besturn"] = "Bestune"
		,["Bianchi (Unternehmen)"] = "Bianchi-Automobil"
		,["Bisu (Automarke)"] = "Bisu (Automarke)"
		,["Bitter Automobile"] = "Bitter (Automarke)"
		,["BMW-Pkw"] = "BMW-Automobil"
		,["BMW (Automarke)"] = "BMW-Automobil"
		,["BMW i"] = "BMW-Automobil"
		,["Bond Cars"] = "Bond Cars"
		,["Borgward"] = "Borgward-Automobil"
		,["Borgward (chinesische Automarke)"] = "Borgward (chinesische Automarke)"
		,["Brabus"] = "Brabus"
		,["Brilliance"] = "Brilliance"
		,["Bristol Cars"] = "Bristol Cars"
		,["Bugatti"] = "Bugatti-Automobil"
		,["Bugatti Automobili"] = "Bugatti Automobili"
		,["Bugatti Automobiles"] = "Bugatti Automobiles"
		,["Buick"] = "Buick-Automobil"
		,["Buick (chinesische Automarke)"] = "Buick (chinesische Automarke)"
		,["BYD Auto"] = "BYD Auto"
		,["Cadillac"] = "Cadillac-Automobil"
		,["Champion (deutsche Automarke)"] = "Champion (deutsche Automarke)"
		,["Changan"] = "Changan"
		,["Chery (Automarke)"] = "Chery (Automarke)"
		,["Chevrolet"] = "Chevrolet-Automobil"
		,["Chrysler"] = "Chrysler"
		,["Citroën"] = "Citroën-Automobil"
		,["Continental Division"] = "Continental Division"
		,["Corvette"] = "Chevrolet-Automobil"
		,["Automobile Dacia"] = "Dacia"
		,["GM Daewoo"] = "GM Daewoo"
		,["DAF (Automobile)"] = "DAF"
		,["Daihatsu"] = "Daihatsu"
		,["Daimler-Motoren-Gesellschaft"] = "Daimler-Motoren-Gesellschaft"
		,["Daimler Motor Company"] = "Daimler Motor Company"
		,["Datsun"] = "Datsun"
		,["De Dion-Bouton"] = "De-Dion-Bouton-Automobil"
		,["De Tomaso"] = "De Tomaso"
		,["Automobiles Delahaye"] = "Delahaye-Automobil"
		,["Derby (Automarke)"] = "Derby (Automarke)"
		,["DKW"] = "DKW-Automobil"
		,["Dodge"] = "Dodge-Automobil"
		,["Dongfeng (Automarke)"] = "Dongfeng (Automarke)"
		,["DS Automobiles"] = "DS Automobiles"
		,["Eagle (US-amerikanische Automarke)"] = "American Motors Corporation"
		,["Edsel"] = "Edsel"
		,["Emgrand"] = "Geely"
		,["Excalibur Automobile Corporation"] = "Excalibur Automobile Corporation"
		,["FAW (Automarke)"] = "FAW (Automarke)"
		,["Facel"] = "Facel"
		,["Ferrari"] = "Ferrari-Automobil"
		,["Fiat (Marke)"] = "Fiat-Automobil"
		,["Ford"] = "Ford-Automobil"
		,["Ford of Britain"] = "Ford-Automobil"
		,["Freight Rover"] = "Freight Rover"
		,["Fuldamobil"] = "Fuldamobil"
		,["GAC (Automarke)"] = "GAC (Automarke)"
		,["Gorkowski Awtomobilny Sawod"] = "Gorkowski Awtomobilny Sawod"
		,["General Motors"] = "General Motors"
		,["Hans Glas GmbH"] = "Hans Glas GmbH"
		,["GMC (Automarke)"] = "GMC-Automobil"
		,["Gonow"] = "Gonow"
		,["Geely (Automarke)"] = "Geely (Automarke)"
		,["Goliath (Automobilhersteller)"] = "Goliath (Automobilhersteller)"
		,["Great Wall Motor"] = "Great Wall Motor"
		,["Haima (Automarke)"] = "Haima (Automarke)"
		,["Haval"] = "Haval"
		,["Hillman (Unternehmen)"] = "Hillman"
		,["Hino Jidōsha"] = "Hino Jidōsha"
		,["Holden (Automarke)"] = "Holden-Automobil"
		,["Holland Car"] = "Holland Car"
		,["Honda"] = "Honda-Automobil"
		,["Hongqi"] = "Hongqi"
		,["Horch"] = "Horch"
		,["Huansu"] = "Huansu"
		,["Humber (Automarke)"] = "Humber (Automarke)"
		,["Hummer (Automarke)"] = "General Motors"
		,["Hyundai Motor Company"] = "Hyundai-Automobil"
		,["Industrieverband Fahrzeugbau"] = "Industrieverband Fahrzeugbau"
		,["Barkas"] = "Industrieverband Fahrzeugbau"
		,["Imperial (Automarke)"] = "Chrysler"
		,["Infiniti"] = "Infiniti"
		,["Innocenti"] = "Innocenti"
		,["Ischmasch"] = "Ischmasch-Automobil"
		,["Iso Rivolta"] = "Iso Rivolta"
		,["Isotta Fraschini"] = "Isotta Fraschini"
		,["Isuzu"] = "Isuzu"
		,["Iveco"] = "Iveco"
		,["Jaguar Cars"] = "Jaguar-Automobil"
		,["Jeep"] = "Jeep"
		,["Jensen Motors"] = "Jensen"
		,["Kia Motors"] = "Kia-Automobil"
		,["Lagonda"] = "Aston Martin"
		,["Lamborghini"] = "Lamborghini"
		,["Lancia"] = "Lancia"
		,["Land Rover"] = "Land Rover"
		,["LDV Limited"] = "LDV (Van)"
		,["Lexus"] = "Lexus"
		,["Leyland Motors"] = "Leyland Motors"
		,["Lincoln (Automarke)"] = "Lincoln"
		,["Lion-Peugeot"] = "Lion-Peugeot"
		,["Lloyd (Automarke)"] = "Lloyd (Automarke)"
		,["Lola Cars"] = "Lola Cars"
		,["Lotus Cars"] = "Lotus Cars"
		,["Maico"] = "Maico"
		,["Maruti Suzuki India"] = "Maruti"
		,["Maserati"] = "Maserati-Automobil"
		,["Maybach-Manufaktur"] = "Maybach"
		,["Mazda"] = "Mazda-Automobil"
		,["McLaren Automotive"] = "McLaren"
		,["Mercedes-Benz-PKW"] = "Mercedes-Benz-Automobil"
		,["Mercury (Automarke)"] = "Mercury"
		,["MG (britische Automarke)"] = "MG (britische Automarke)"
		,["MG (chinesische Automarke)"] = "MG (chinesische Automarke)"
		,["Miele"] = "Miele"
		,["Mitsubishi Motors"] = "Mitsubishi Motors"
		,["Automobile Monteverdi"] = "Automobile Monteverdi"
		,["Société A. Marguerite"] = "Société A. Marguerite"
		,["Morris Motor Company"] = "Morris"
		,["Moskwitsch"] = "Moskwitsch"
		,["Motobloc"] = "Motobloc"
		,["Nash Motors"] = "Nash"
		,["Nesselsdorfer Wagenbau-Fabriks-Gesellschaft"] = "Nesselsdorf"
		,["Nissan"] = "Nissan-Automobil"
		,["NSU Motorenwerke"] = "NSU-Automobil"
		,["Oldsmobile"] = "Oldsmobile-Automobil"
		,["Opel"] = "Opel-Automobil"
		,["Packard (Automobilhersteller)"] = "Packard"
		,["Panhard"] = "Panhard-Automobil"
		,["Panhard & Levassor"] = "Panhard&Levassor-Pkw"
		,["Peugeot"] = "Peugeot-Automobil"
		,["Piaggio"] = "Piaggio"
		,["Plymouth (Automarke)"] = "Plymouth (Automarke)"
		,["Pontiac (Automarke)"] = "Pontiac-Automobil"
		,["Porsche"] = "Porsche"
		,["Praga (Unternehmen)"] = "Praga (Unternehmen)"
		,["Prince Jidōsha Kōgyō"] = "Prince Jidōsha Kōgyō"
		,["Protek Gesellschaft für Industrieentwicklungen"] = "Protek Gesellschaft für Industrieentwicklungen"
		,["Proton (Automobilhersteller)"] = "Proton"
		,["Reliant"] = "Reliant"
		,["Renault"] = "Renault-Automobil"
		,["Riley"] = "Riley"
		,["Rolls-Royce Motor Cars"] = "Rolls-Royce-Automobil"
		,["Rover (Automobilhersteller)"] = "Rover"
		,["Roewe"] = "Roewe"
		,["Saab Automobile"] = "Saab Automobile"
		,["Saab-Valmet"] = "Saab Automobile"
		,["Renault Samsung Motors"] = "Samsung"
		,["Saporisky Awtomobilebudiwny Sawod"] = "Saporisky Awtomobilebudiwny Sawod"
		,["Saturn Corporation"] = "General Motors"
		,["Sawod imeni Lichatschowa"] = "Sawod imeni Lichatschowa"
		,["Scion"] = "Scion"
		,["Seat"] = "Seat"
		,["Shijiazhuang Shuanghuan Automobile"] = "Shijiazhuang Shuanghuan Automobile"
		,["Simca"] = "Simca"
		,["Škoda Auto"] = "Škoda-Automobil"
		,["Smart (Automarke)"] = "Smart"
		,["Speranza (Automarke)"] = "Speranza (Automarke)"
		,["SsangYong Motor Company"] = "SsangYong"
		,["Standard Motor Company"] = "Standard Motor Company"
		,["Steyr-Daimler-Puch"] = "Steyr (Unternehmen)"
		,["Studebaker Corporation"] = "Studebaker"
		,["Subaru"] = "Subaru"
		,["Sunbeam"] = "Sunbeam"
		,["Suzuki"] = "Suzuki-Automobil"
		,["Talbot (Automarke)"] = "Talbot (Automarke)"
		,["Tata Motors"] = "Tata"
		,["Tatra (Unternehmen)"] = "Tatra"
		,["Tesla, Inc."] = "Tesla-Automobil"
		,["Toyopet"] = "Toyota-Automobil"
		,["Toyota"] = "Toyota-Automobil"
		,["Trabant (Pkw)"] = "Industrieverband Fahrzeugbau"
		,["Triumph (Auto)"] = "Triumph-Automobil"
		,["TVR"] = "TVR"
		,["Uljanowski Awtomobilny Sawod"] = "Uljanowski Awtomobilny Sawod"
		,["Vanden Plas (England)"] = "Vanden Plas"
		,["Vauxhall Motors"] = "Vauxhall-Automobil"
		,["Venucia"] = "Venucia"
		,["Volkswagen"] = "Volkswagen-Automobil"
		,["Volvo Car Corporation"] = "Volvo-Automobil"
		,["Wanderer-Werke"] = "Wanderer-Werke"
		,["Wartburg (Automarke)"] = "Industrieverband Fahrzeugbau"
		,["Wey (Automarke)"] = "Wey (Automarke)"
		,["Willys-Overland"] = "Willys-Overland"
		,["Willys-Overland do Brazil"] = "Willys-Overland"
		,["Wolga (Automarke)"] = "Gorkowski Awtomobilny Sawod"
		,["Wolseley Motor Company"] = "Wolseley"
		,["Yenko Sportscars"] = "Yenko"
		,["Zastava"] = "Zastava"
		,["Saporisky Awtomobilebudiwny Sawod"] = "Saporisky Awtomobilebudiwny Sawod"
		,["Sawod imeni Lichatschowa"] = "Sawod imeni Lichatschowa"
		,["Zündapp"] = "Zündapp"
		}

	local cat = tab_cat[marke]
		
	if cat ~= nil then
		wiki_markup_cat = "[[Kategorie:" .. cat .. "|"
		if modell ~= "" then
			wiki_markup_cat = wiki_markup_cat .. modell
		else			
			wiki_markup_cat = wiki_markup_cat .. "{{PAGENAME}}"
		end			
			
		wiki_markup_cat = wiki_markup_cat .. "]]"
	end

	return wiki_markup_cat
		
end

function p.extractLinkTarget(frame)
--[[  
	Ersten Link-Target aus Wiki-Markup extrahieren. 
	Wenn kein Wiki-Link enthalten ist, dann gesamten Text zurückgeben.
	Parameter: 
	*	Wiki-Markup
]]
	return p._extractLinkTarget(frame.args[1])
end

--[[ Hilfsfunktionen
----------------------
]]

function p._extractLinkTarget(wiki_markup)
--[[  
	Ersten Link-Target aus Wiki-Markup extrahieren. 
	Wenn kein Wiki-Link enthalten ist, dann gesamten Text zurückgeben.
	Parameter: 
	*	Wiki-Markup
]]
	local link_target = wiki_markup
	local pos_startlink = mw.ustring.find(wiki_markup, "[[", 1, true)
	if pos_startlink ~= nil then
		local pos_endlink = mw.ustring.find(wiki_markup, "]]", pos_startlink+1, true)
		if pos_endlink ~= nil then
			local pos_pipe = mw.ustring.find(wiki_markup, "|", pos_startlink+1, true)
			if pos_pipe ~= nil and pos_pipe < pos_endlink then
				link_target = mw.ustring.sub(wiki_markup, pos_startlink+2, pos_pipe-1)
			else
				link_target = mw.ustring.sub(wiki_markup, pos_startlink+2, pos_endlink-1)
			end
		end
	end
	return link_target
end

return p