Jump to content

Module:Flags

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by QuimGil (talk | contribs) at 04:05, 4 June 2013 (Table renamed: translations.fullName). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

-- Loading the flag translations module --
-- FIXME: include a short list of popular flags here (United States, China...) to avoid loading the module just for them
local translations = require "Module:Sandbox/QuimGil/FlagTranslations"

-- Assigning the parameter to a flag and a link
function p.flag(territory)
-- No border for Nepal or Ohio
-- FIXME: there should be a table of flags without border
    if territory.args[1] == "Nepal" or territory.args[1] == "Ohio" then 
        return '[[File:Flag_of_' .. territory.args[1] .. '.svg|link=' .. territory.args[1] .. '|22x20px]]' end
-- Searching in the translation table.
    for english,locale in pairs(translations.fullName) do 
    if territory.args[1] == locale or territory.args[1] == english then commonsName = english link = locale end
-- Fallback to Commons when the parameter doesn't have a translation in the table. The flag doesn't have a link, then.    
    if commonsName == nil then commonsName = territory.args[1] link = territory.args[1] end
    end
    return '[[File:Flag_of_' .. commonsName .. '.svg|border|link=' .. link .. '|22x20px]]'
end
return p