Modul:Vorlage:Flagicon
aus Wikipedia, der freien Enzyklopädie
Dies ist die aktuelle Version dieser Seite, zuletzt bearbeitet am 24. September 2013 um 07:38 Uhr durch imported>Schnark(522406) (title wird bei unverlinkten Bildern ohnehin nicht verwendet, kann also wegfallen; vorheriger Kommentar sollte lauten: Flagge nicht verlinken, falls ohnehin Link dahinter kommt, verlinktes Bild ohne alt-Text kann Screenreader verwirren).
Die Dokumentation für dieses Modul kann unter Modul:Vorlage:Flagicon/Doku erstellt werden
--[[
Standardwerte zu einem Flaggencode, bestehend aus
1: Dateiname
2: Linkziel
text: Linktext/Tooltip (optional)
sortkey: Sortierschlüssel (optional)
border: Flagge braucht Rahmen
]]
local defaultData = {}
defaultData["AFG"] = {"Flag of Afghanistan.svg", "Afghanistan"}
defaultData["AGO"] = {"Flag of Angola.svg", "Angola"}
defaultData["ALB"] = {"Flag of Albania.svg", "Albanien"}
defaultData["AND"] = {"Flag of Andorra.svg", "Andorra"}
defaultData["ARE"] = {"Flag of the United Arab Emirates.svg", "Vereinigte Arabische Emirate"}
defaultData["ARG"] = {"Flag of Argentina.svg", "Argentinien"}
defaultData["ARM"] = {"Flag of Armenia.svg", "Armenien"}
defaultData["ATG"] = {"Flag of Antigua and Barbuda.svg", "Antigua und Barbuda"}
defaultData["AUS"] = {"Flag of Australia.svg", "Australien"}
defaultData["AUT"] = {"Flag of Austria.svg", "Österreich"}
defaultData["AZE"] = {"Flag of Azerbaijan.svg", "Aserbaidschan"}
defaultData["BDI"] = {"Flag of Burundi.svg", "Burundi"}
defaultData["BEL"] = {"Flag of Belgium (civil).svg", "Belgien"}
defaultData["BEN"] = {"Flag of Benin.svg", "Benin"}
defaultData["BFA"] = {"Flag of Burkina Faso.svg", "Burkina Faso"}
defaultData["BGD"] = {"Flag of Bangladesh.svg", "Bangladesch"}
defaultData["BGR"] = {"Flag of Bulgaria.svg", "Bulgarien", border = true}
defaultData["BHR"] = {"Flag of Bahrain.svg", "Bahrain", border = true}
defaultData["BHS"] = {"Flag of the Bahamas.svg", "Bahamas"}
defaultData["BIH"] = {"Flag of Bosnia and Herzegovina.svg", "Bosnien und Herzegowina"}
defaultData["BLR"] = {"Flag of Belarus.svg", "Weißrussland", border = true}
defaultData["BLZ"] = {"Flag of Belize.svg", "Belize"}
defaultData["BOL"] = {"Flag of Bolivia.svg", "Bolivien"}
defaultData["BRA"] = {"Flag of Brazil.svg", "Brasilien"}
defaultData["BRB"] = {"Flag of Barbados.svg", "Barbados"}
defaultData["BRN"] = {"Flag of Brunei.svg", "Brunei"}
defaultData["BTN"] = {"Flag of Bhutan.svg", "Bhutan"}
defaultData["BWA"] = {"Flag of Botswana.svg", "Botswana"}
defaultData["CAF"] = {"Flag of the Central African Republic.svg", "Zentralafrikanische Republik", border = true}
defaultData["CAN"] = {"Flag of Canada.svg", "Kanada", border = true}
defaultData["CHE"] = {"Flag of Switzerland within 2to3.svg", "Schweiz"}
defaultData["CHL"] = {"Flag of Chile.svg", "Chile", border = true}
defaultData["CHN"] = {"Flag of the People's Republic of China.svg", "Volksrepublik China", text = "China", sortkey = "China Volksrepublik"}
defaultData["CIV"] = {"Flag of Côte d'Ivoire.svg", "Elfenbeinküste", border = true}
defaultData["CMR"] = {"Flag of Cameroon.svg", "Kamerun", border = true}
defaultData["COD"] = {"Flag of the Democratic Republic of the Congo.svg", "Demokratische Republik Kongo", sortkey = "Kongo Demokratische Republik"}
defaultData["COG"] = {"Flag of the Republic of the Congo.svg", "Republik Kongo", sortkey = "Kongo Republik"}
defaultData["COK"] = {"Flag of the Cook Islands.svg", "Cookinseln"}
defaultData["COL"] = {"Flag of Colombia.svg", "Kolumbien"}
defaultData["COM"] = {"Flag of the Comoros.svg", "Komoren"}
defaultData["CPV"] = {"Flag of Cape Verde.svg", "Kap Verde"}
defaultData["CRI"] = {"Flag of Costa Rica.svg", "Costa Rica"}
defaultData["CUB"] = {"Flag of Cuba.svg", "Kuba", border = true}
defaultData["CYP"] = {"Flag of Cyprus.svg", "Republik Zypern", text = "Zypern", sortkey = "Zypern Republik", border = true}
defaultData["CZE"] = {"Flag of the Czech Republic.svg", "Tschechien", border = true}
defaultData["DEU"] = {"Flag of Germany.svg", "Deutschland"}
defaultData["DJI"] = {"Flag of Djibouti.svg", "Dschibuti", border = true}
defaultData["DMA"] = {"Flag of Dominica.svg", "Dominica"}
defaultData["DNK"] = {"Flag of Denmark.svg", "Dänemark"}
defaultData["DOM"] = {"Flag of the Dominican Republic.svg", "Dominikanische Republik"}
defaultData["DZA"] = {"Flag of Algeria.svg", "Algerien"}
defaultData["ECU"] = {"Flag of Ecuador.svg", "Ecuador"}
defaultData["EGY"] = {"Flag of Egypt.svg", "Ägypten"}
defaultData["ERI"] = {"Flag of Eritrea.svg", "Eritrea"}
defaultData["ESP"] = {"Flag of Spain.svg", "Spanien"}
defaultData["EST"] = {"Flag of Estonia.svg", "Estland", border = true}
defaultData["ETH"] = {"Flag of Ethiopia.svg", "Äthiopien"}
defaultData["FIN"] = {"Flag of Finland.svg", "Finnland", border = true}
defaultData["FJI"] = {"Flag of Fiji.svg", "Fidschi"}
defaultData["FRA"] = {"Flag of France.svg", "Frankreich", border = true}
defaultData["FSM"] = {"Flag of the Federated States of Micronesia.svg", "Föderierte Staaten von Mikronesien", text = "Mikronesien"}
defaultData["GAB"] = {"Flag of Gabon.svg", "Gabun"}
defaultData["GBR"] = {"Flag of the United Kingdom.svg", "Vereinigtes Königreich"}
defaultData["GEO"] = {"Flag of Georgia.svg", "Georgien", border = true}
defaultData["GHA"] = {"Flag of Ghana.svg", "Ghana"}
defaultData["GIN"] = {"Flag of Guinea.svg", "Guinea"}
defaultData["GMB"] = {"Flag of The Gambia.svg", "Gambia"}
defaultData["GNB"] = {"Flag of Guinea-Bissau.svg", "Guinea-Bissau"}
defaultData["GNQ"] = {"Flag of Equatorial Guinea.svg", "Äquatorialguinea"}
defaultData["GRC"] = {"Flag of Greece.svg", "Griechenland"}
defaultData["GRD"] = {"Flag of Grenada.svg", "Grenada"}
defaultData["GTM"] = {"Flag of Guatemala.svg", "Guatemala"}
defaultData["GUY"] = {"Flag of Guyana.svg", "Guyana"}
defaultData["HND"] = {"Flag of Honduras.svg", "Honduras"}
defaultData["HRV"] = {"Flag of Croatia.svg", "Kroatien"}
defaultData["HTI"] = {"Flag of Haiti (civil).svg", "Haiti"}
defaultData["HUN"] = {"Flag of Hungary.svg", "Ungarn"}
defaultData["IDN"] = {"Flag of Indonesia.svg", "Indonesien", border = true}
defaultData["IND"] = {"Flag of India.svg", "Indien"}
defaultData["IRL"] = {"Flag of Ireland.svg", "Irland", border = true}
defaultData["IRN"] = {"Flag of Iran.svg", "Iran"}
defaultData["IRQ"] = {"Flag of Iraq.svg", "Irak"}
defaultData["ISL"] = {"Flag of Iceland.svg", "Island"}
defaultData["ISR"] = {"Flag of Israel.svg", "Israel", border = true}
defaultData["ITA"] = {"Flag of Italy.svg", "Italien", border = true}
defaultData["JAM"] = {"Flag of Jamaica.svg", "Jamaika"}
defaultData["JOR"] = {"Flag of Jordan.svg", "Jordanien"}
defaultData["JPN"] = {"Flag of Japan.svg", "Japan", border = true}
defaultData["KAZ"] = {"Flag of Kazakhstan.svg", "Kasachstan"}
defaultData["KEN"] = {"Flag of Kenya.svg", "Kenia"}
defaultData["KGZ"] = {"Flag of Kyrgyzstan.svg", "Kirgisistan"}
defaultData["KHM"] = {"Flag of Cambodia.svg", "Kambodscha"}
defaultData["KIR"] = {"Flag of Kiribati.svg", "Kiribati"}
defaultData["KNA"] = {"Flag of Saint Kitts and Nevis.svg", "St. Kitts und Nevis"}
defaultData["KOR"] = {"Flag of South Korea.svg", "Südkorea", sortkey = "Korea Süd", border = true}
defaultData["KWT"] = {"Flag of Kuwait.svg", "Kuwait"}
defaultData["LAO"] = {"Flag of Laos.svg", "Laos"}
defaultData["LBN"] = {"Flag of Lebanon.svg", "Libanon", border = true}
defaultData["LBR"] = {"Flag of Liberia.svg", "Liberia"}
defaultData["LBY"] = {"Flag of Libya.svg", "Libyen"}
defaultData["LCA"] = {"Flag of Saint Lucia.svg", "St. Lucia"}
defaultData["LIE"] = {"Flag of Liechtenstein.svg", "Liechtenstein"}
defaultData["LKA"] = {"Flag of Sri Lanka.svg", "Sri Lanka"}
defaultData["LSO"] = {"Flag of Lesotho.svg", "Lesotho"}
defaultData["LTU"] = {"Flag of Lithuania.svg", "Litauen"}
defaultData["LUX"] = {"Flag of Luxembourg.svg", "Luxemburg"}
defaultData["LVA"] = {"Flag of Latvia.svg", "Lettland"}
defaultData["MAR"] = {"Flag of Morocco.svg", "Marokko"}
defaultData["MCO"] = {"Flag of Monaco.svg", "Monaco", border = true}
defaultData["MDA"] = {"Flag of Moldova.svg", "Moldawien"}
defaultData["MDG"] = {"Flag of Madagascar.svg", "Madagaskar", border = true}
defaultData["MDV"] = {"Flag of Maldives.svg", "Malediven"}
defaultData["MEX"] = {"Flag of Mexico.svg", "Mexiko", border = true}
defaultData["MHL"] = {"Flag of the Marshall Islands.svg", "Marshallinseln"}
defaultData["MKD"] = {"Flag of Macedonia.svg", "Mazedonien"}
defaultData["MLI"] = {"Flag of Mali.svg", "Mali"}
defaultData["MLT"] = {"Flag of Malta.svg", "Malta", border = true}
defaultData["MMR"] = {"Flag of Myanmar.svg", "Myanmar"}
defaultData["MNE"] = {"Flag of Montenegro.svg", "Montenegro"}
defaultData["MNG"] = {"Flag of Mongolia.svg", "Mongolei"}
defaultData["MOZ"] = {"Flag of Mozambique.svg", "Mosambik"}
defaultData["MRT"] = {"Flag of Mauritania.svg", "Mauretanien"}
defaultData["MUS"] = {"Flag of Mauritius.svg", "Mauritius"}
defaultData["MWI"] = {"Flag of Malawi.svg", "Malawi"}
defaultData["MYS"] = {"Flag of Malaysia.svg", "Malaysia"}
defaultData["NAM"] = {"Flag of Namibia.svg", "Namibia"}
defaultData["NER"] = {"Flag of Niger.svg", "Niger"}
defaultData["NGA"] = {"Flag of Nigeria.svg", "Nigeria"}
defaultData["NIC"] = {"Flag of Nicaragua.svg", "Nicaragua"}
defaultData["NLD"] = {"Flag of the Netherlands.svg", "Niederlande"}
defaultData["NOR"] = {"Flag of Norway.svg", "Norwegen"}
defaultData["NPL"] = {"Flag of Nepal (with spacing).svg", "Nepal"}
defaultData["NRU"] = {"Flag of Nauru.svg", "Nauru"}
defaultData["NZL"] = {"Flag of New Zealand.svg", "Neuseeland"}
defaultData["OMN"] = {"Flag of Oman.svg", "Oman", border = true}
defaultData["PAK"] = {"Flag of Pakistan.svg", "Pakistan", border = true}
defaultData["PAN"] = {"Flag of Panama.svg", "Panama", border = true}
defaultData["PER"] = {"Flag of Peru.svg", "Peru", border = true}
defaultData["PHL"] = {"Flag of the Philippines.svg", "Philippinen"}
defaultData["PLW"] = {"Flag of Palau.svg", "Palau"}
defaultData["PNG"] = {"Flag of Papua New Guinea.svg", "Papua-Neuguinea"}
defaultData["POL"] = {"Flag of Poland.svg", "Polen", border = true}
defaultData["PRK"] = {"Flag of North Korea.svg", "Nordkorea", sortkey = "Korea Nord", border = true}
defaultData["PRT"] = {"Flag of Portugal.svg", "Portugal"}
defaultData["PRY"] = {"Flag of Paraguay.svg", "Paraguay"}
defaultData["QAT"] = {"Flag of Qatar.svg", "Katar", border = true}
defaultData["ROU"] = {"Flag of Romania.svg", "Rumänien"}
defaultData["RUS"] = {"Flag of Russia.svg", "Russland", border = true}
defaultData["RWA"] = {"Flag of Rwanda.svg", "Ruanda"}
defaultData["SAU"] = {"Flag of Saudi Arabia.svg", "Saudi-Arabien"}
defaultData["SDN"] = {"Flag of Sudan.svg", "Sudan"}
defaultData["SSD"] = {"Flag of South Sudan.svg", "Südsudan"}
defaultData["SEN"] = {"Flag of Senegal.svg", "Senegal"}
defaultData["SGP"] = {"Flag of Singapore.svg", "Singapur", border = true}
defaultData["SLB"] = {"Flag of the Solomon Islands.svg", "Salomonen"}
defaultData["SLE"] = {"Flag of Sierra Leone.svg", "Sierra Leone"}
defaultData["SLV"] = {"Flag of El Salvador.svg", "El Salvador"}
defaultData["SMR"] = {"Flag of San Marino.svg", "San Marino", border = true}
defaultData["SOM"] = {"Flag of Somalia.svg", "Somalia"}
defaultData["SRB"] = {"Flag of Serbia.svg", "Serbien", border = true}
defaultData["STP"] = {"Flag of Sao Tome and Principe.svg", "São Tomé und Príncipe", sortkey = "Sao Tome und Principe"}
defaultData["SUR"] = {"Flag of Suriname.svg", "Suriname"}
defaultData["SVK"] = {"Flag of Slovakia.svg", "Slowakei", border = true}
defaultData["SVN"] = {"Flag of Slovenia.svg", "Slowenien", border = true}
defaultData["SWE"] = {"Flag of Sweden.svg", "Schweden"}
defaultData["SWZ"] = {"Flag of Swaziland.svg", "Swasiland"}
defaultData["SYC"] = {"Flag of the Seychelles.svg", "Seychellen"}
defaultData["SYR"] = {"Flag of Syria.svg", "Syrien"}
defaultData["TCD"] = {"Flag of Chad.svg", "Tschad"}
defaultData["TGO"] = {"Flag of Togo.svg", "Togo"}
defaultData["THA"] = {"Flag of Thailand.svg", "Thailand"}
defaultData["TJK"] = {"Flag of Tajikistan.svg", "Tadschikistan"}
defaultData["TKM"] = {"Flag of Turkmenistan.svg", "Turkmenistan"}
defaultData["TLS"] = {"Flag of East Timor.svg", "Osttimor"}
defaultData["TON"] = {"Flag of Tonga.svg", "Tonga", border = true}
defaultData["TTO"] = {"Flag of Trinidad and Tobago.svg", "Trinidad und Tobago"}
defaultData["TUN"] = {"Flag of Tunisia.svg", "Tunesien"}
defaultData["TUR"] = {"Flag of Turkey.svg", "Türkei"}
defaultData["TUV"] = {"Flag of Tuvalu.svg", "Tuvalu"}
defaultData["TZA"] = {"Flag of Tanzania.svg", "Tansania"}
defaultData["UGA"] = {"Flag of Uganda.svg", "Uganda"}
defaultData["UKR"] = {"Flag of Ukraine.svg", "Ukraine"}
defaultData["URY"] = {"Flag of Uruguay.svg", "Uruguay", border = true}
defaultData["USA"] = {"Flag of the United States (Pantone).svg", "Vereinigte Staaten"}
defaultData["UZB"] = {"Flag of Uzbekistan.svg", "Usbekistan"}
defaultData["VAT"] = {"Flag of the Vatican City.svg", "Vatikanstadt", border = true} --TODO: Bild mit normaler Breite nehmen (dieses braucht 13px)
defaultData["VCT"] = {"Flag of Saint Vincent and the Grenadines.svg", "St. Vincent und die Grenadinen"}
defaultData["VEN"] = {"Flag of Venezuela.svg", "Venezuela"}
defaultData["VNM"] = {"Flag of Vietnam.svg", "Vietnam"}
defaultData["VUT"] = {"Flag of Vanuatu.svg", "Vanuatu"}
defaultData["WSM"] = {"Flag of Samoa.svg", "Samoa"}
defaultData["YEM"] = {"Flag of Yemen.svg", "Jemen"}
defaultData["ZAF"] = {"Flag of South Africa.svg", "Südafrika"}
defaultData["ZMB"] = {"Flag of Zambia.svg", "Sambia"}
defaultData["ZWE"] = {"Flag of Zimbabwe.svg", "Simbabwe"}
--[[
Bestimmt Standardwerte zu einem Flaggencode in der Reihenfolge:
# Dateiname
# Linkziel
# Linktext
# Tooltip
# Sortierschlüssel
# Rahmen
]]
local function getDefaults (code)
local def = defaultData[code]
if def == nil then
return nil
end
local file = def[1]
local link = def[2]
local text = def.text or def[2]
--Leerzeichen unter ersten 7 Zeichen durch NBSP ersetzen (entspricht der bisherigen Praxis)
local text1 = string.sub(text, 0, 7)
local text2 = string.sub(text, 8)
local dummy
text1, dummy = string.gsub(text1, " ", " ")
text = text1 .. text2
local title = def.text or def[2]
local sortkey = def.sortkey or def.text or def[2]
local border = def.border
return {file, link, text, title, sortkey, border}
end
--[[
Erzeugt Flaggenicon ohne Text dahinter
* file: Dateiname (ohne Namensraum)
* width: Parameter für Breite (etwa "20px" oder "border|18px")
* link: Linkziel
* title: Titel, wird verwendet als Tooltip, alt-Attribut und damit auch als Sortierschlüssel
* sortkey: Sortierschlüssel, wird verwendet, falls abweichend von title
]]
local function flagWithoutText (file, width, link, title, sortkey)
if sortkey == title then
sortkey = "" --kein Sortierschlüssel nötig
else
sortkey = "<span style='display:none;'>" .. sortkey .. "</span>"
end
return sortkey .. "[[File:" .. file .. "|" .. width .. "|link=" .. link .. "|" .. title .. "]]"
end
--[[
Erzeugt Flaggenicon mit Text dahinter
* file: Dateiname (ohne Namensraum)
* width: Parameter für Breite (etwa "20px" oder "border|18px")
* link: Linkziel
* text: Text des Links
* sortkey: Sortierschlüssel
Das alt-Attribut wird ausdrücklich leer gelassen, die Flagge selbst nicht verlinkt (siehe https://de.wikipedia.org/w/index.php?title=Wikipedia_Diskussion:L%C3%A4ndervorlagen_mit_Flagge&oldid=86299502#Barrierefreies_Internet).
]]
local function flagWithText (file, width, link, text, sortkey)
return "<span style='display:none;'>" .. sortkey .. "</span>[[File:" .. file .. "|" .. width .. "|link=|alt=]] [[" .. link .. "|" .. text .. "]]"
end
--[[
Erzeugt Flaggenicon aus Parametern
* code: Code für Flagge
* args: an Vorlage übergebene Argumente
]]
local function flag (code, args)
local defaults = getDefaults(code)
if defaults == nil then
return "<span class='error'>Unbekannter Flaggencode</span>"
end
local file = defaults[1]
local link = args["Ziel"] or args[1] or defaults[2]
local text = args["Ziel"] or args[2] or defaults[3]
local title = args[3] or defaults[4]
local sortkey = args[3] or defaults[5]
local width = args["WIDTH"] or 20
if defaults[6] then
width = "border|" .. (width - 2) .. "px"
else
width = width .. "px"
end
if args[1] == "#" then
if link == "#" then
link = defaults[2]
end
return flagWithoutText(file, width, link, title, sortkey)
else
return flagWithText(file, width, link, text, sortkey)
end
end
--Export
local p = {}
function p.debug (code, args)
return flag(code, args)
end
function p.f (frame)
local args = frame:getParent().args
local code = frame.args[1]
return flag(code, args)
end
return p