Module:Flags: Difference between revisions

Content deleted Content added
Converts "Flag of " in a variable in order to accept images that don't follow this name schema
Supporting label parameter, and adding a "?" fallback flag for variant / label flags not found in FlagTranslations
Line 1:
local p = {}
 
-- Loading the flag translations module --
local translations = mw.loadData("Module:Sandbox/QuimGil/FlagTranslations")
-- Converts "Flag of " in a variable in order to accept images that don't follow this name schema
flagOf = "Flag_of_"
-- Assigning the parameter to a flag and a link
Line 44 ⟶ 47:
end
 
-- Variant check for historical flags --
if territory.args[23] ~= "" then
variant = territory.args[23]
commonsName = translations.variant[commonsName .. "|" .. variant]
flagOf=""
end
 
-- Label check --
if territory.args[2] ~= "{{{2}}}" then
variant = territory.args[2]
commonsName = translations.variant[commonsName .. "|" .. variant]
flagOf = ""
end
 
-- Fallback for non-identified variant/label flags --
if commonsName == nil then
commonsName = "Flag of None"
end
 
Line 65 ⟶ 81:
end
-- Checking whether a size parameter has been introduced, otherwise set default
if territory.args[34]:find("px", -2) ~= nil then
size = territory.args[34]
else
size = defaultSize(commonsName)
end
 
return '[[File:Flag_of_' .. flagOf .. commonsName .. '.svg|' .. border .. 'link=' .. link .. '|'.. size .. ']]'
-- Converts "Flag of " in a variable in order to accept images that don't follow this name schema
flagOf = "Flag_of_"
-- Returns the full value for the template
return '[[File:Flag_of_' .. commonsName .. '.svg|' .. border .. 'link=' .. link .. '|'.. size .. ']]'
end
return p