Module:Flag: Difference between revisions

From Inkipedia, the Splatoon wiki
m (fix Undisclosed handling to show Flag.svg in default cases)
(Added Austria. DaDoc540 requested this because the country participates in Splatoon 3 European Championship 2023.)
Line 3: Line 3:
local flag_map = {
local flag_map = {
     ["au"] = "Australia",
     ["au"] = "Australia",
    ["at"] = "Austria",
     ["be"] = "Belgium",
     ["be"] = "Belgium",
     ["br"] = "Brazil",
     ["br"] = "Brazil",

Revision as of 00:42, 9 January 2024

{{flag|<2 letter abbreviation>|<size>}}

Size is 20x20 by default. px is not necessary.

Current regions supported

Type the ISO 3166-1 code in lower-case for use in template.

Region name ISO 3166-1 code Output
Argentina AR Undisclosed
Australia AU Australia
Austria AT Austria
Belgium BE Belgium
Brazil BR Brazil
Canada CA Canada
Canada and France CAFR[1] CanadaFrance
China CN China
Cuba CU Cuba
Czech Republic CZ CzechRepublic
Denmark DK Undisclosed
Europe EU Europe
Finland FI Finland
France FR France
Germany DE Germany
Greece GR Greece
Hong Kong HK Hong Kong
Hungary HU Hungary
India IN India
Indonesia ID Indonesia
Ireland IE Ireland
Israel IL Israel
Italy IT Italy
Japan JP Japan
Malaysia MY Malaysia
Mexico MX Mexico
Netherlands NL Netherlands
North Korea KP North Korea
Norway NO Norway
Panama PA Undisclosed
Philippines PH Philippines
Poland PL Poland
Portugal PT Portugal
Quebec QC[a] Quebec
Romania RO Romania
Russia RU Russia
South Korea KR South Korea
Spain ES Spain
Spain and Mexico ESMX[1] SpainMexico
Sweden SE Sweden
Singapore SG Singapore
Taiwan TW Taiwan
Thailand TH Thailand
Ukraine UA Undisclosed
United Arab Emirates AE Undisclosed
United Kingdom GB Undisclosed
United States US USA
United Kingdom and United States USGB[1] Undisclosed

Uploading .svg files of country flags and adding them here is allowed. Optionally, you can ask a staff member or user to upload and add a flag.

Notes

  1. Quebec does not have an ISO 3166-1 code; its Canadian postal abbreviation has been used instead.

  1. 1.0 1.1 1.2 Both countries country codes have been combined.
local p = {}

local flag_map = {
    ["au"] = "Australia",
    ["at"] = "Austria",
    ["be"] = "Belgium",
    ["br"] = "Brazil",
    ["ca"] = "Canada",
    ["cafr"] = "CanadaFrance",
    ["ch"] = "Switzerland",
    ["cn"] = "China",
    ["cu"] = "Cuba",
    ["cz"] = "CzechRepublic",
    ["da"] = "Denmark",
    ["de"] = "Germany",
    ["gr"] = "Greece",
    ["es"] = "Spain",
    ["eu"] = "Europe",
    ["esmx"] = "SpainMexico",
    ["fi"] = "Finland",
    ["fr"] = "France",
    ["hk"] = "Hong Kong",
    ["hu"] = "Hungary",
    ["id"] = "Indonesia",
    ["ie"] = "Ireland",
    ["il"] = "Israel",
    ["in"] = "India",
    ["it"] = "Italy",
    ["jp"] = "Japan",
    ["kp"] = "North Korea",
    ["mx"] = "Mexico",
    ["my"] = "Malaysia",
    ["nl"] = "Netherlands",
    ["no"] = "Norway",
    ["ph"] = "Philippines",
    ["pl"] = "Poland",
    ["pt"] = "Portugal",
    ["qc"] = "Quebec",
    ["ro"] = "Romania",
    ["ru"] = "Russia",
    ["se"] = "Sweden",
    ["sg"] = "Singapore",
    ["kr"] = "South Korea",
    ["tw"] = "Taiwan",
    ["th"] = "Thailand",
    ["uk"] = "United Kingdom",
    ["us"] = "USA"
}

function p.main(frame)
    local args = frame:getParent().args
    local countryCode = args[1] or ""
    local size = args["size"] or args[2] or "20x20"
    return p.getFlag(countryCode, size)
end

function p.getFlag(countryCode, size)
    local flagName = flag_map[countryCode] or ""
    return string.format('[[File:Flag%s.svg|border|%spx|link=|%s]]', 
      flagName,
      size,
      (flagName ~= "" and flagName or "Undisclosed"))
end

return p