Module:T/forms

--

-- Data for Module:T. See Global Lua Modules/T/schema for the schema. -- -- @todo Add i18n for each form, e.g. from ParserFunctions.i18n.magic.php. -- @todo Check if case-sensitivity is consistent across language barriers. -- @todo Add missing forms.

local forms = { map = {}, default = nil, }

-- helper function to make the same form available from multiple titles local function Form(data) local titleCount = 0

for title in pairs(data.titles) do       local alias = mw.ustring.lower(title)

if forms.map[alias] then error("duplicate form with title `" .. title .. "` in Dev:T/data") end

forms.map[alias] = data titleCount = titleCount + 1 end

if titleCount > 0 then -- do nothing elseif forms.default then error("duplicate default form in Dev:T/data") else forms.default = data end end

-- t("CURRENTYEAR") -- CURRENTYEAR Form { titles = { ["CURRENTYEAR"] = true, },   caseSensitive = true, skippedDelimiters = 1, minimumArity = 1, knownArgs = { -- "CURRENTYEAR" {           format = "link", target = "mw:Help:Magic words#CURRENTYEAR", },   },    -- {}    extraArgs = nil, }

-- t("#invoke:", "module", "function", "a", "b", "c") -- module Form { titles = { ["#invoke:"] = true, },   caseSensitive = false, skippedDelimiters = 2, minimumArity = 3, knownArgs = { -- "#invoke:" {           format = "syntax", },       -- "module" {           format = "link", target = "Module:%s", },       -- "function" {           format = "syntax", },   },    -- {"a", "b", "c"} extraArgs = { format = "param", parseName = true, }, }

-- t("#if:", "test", "pass", "fail") -- test Form { titles = { ["#if:"] = true, },   caseSensitive = false, skippedDelimiters = 2, minimumArity = 1, knownArgs = { -- "#if:" {           format = "link", target = "mw:Help:Extension:ParserFunctions##if", },       -- "test" {           format = "param", parseName = false, },       -- "pass" {           format = "param", parseName = false, },       -- "fail" {           format = "param", parseName = false, },   },    -- {}    extraArgs = nil, }

-- t("#switch:", "test", "a=one", "b=two", "c=three") -- test Form { titles = { ["#switch:"] = true, },   caseSensitive = false, skippedDelimiters = 2, minimumArity = 1, knownArgs = { -- "#switch:" {           format = "link", target = "mw:Help:Extension:ParserFunctions##switch", },       -- "test" {           format = "param", parseName = false, },   },    -- {"a=one", "b=two", "c=three"} extraArgs = { format = "param", parseName = true, }, }

-- t("template", "a", "b", "c") -- a Form { titles = {}, caseSensitive = true, skippedDelimiters = 1, minimumArity = 1, knownArgs = { -- "template" {           format = "link", target = "Template:%s", },   },    -- {"a", "b", "c"} extraArgs = { format = "param", parseName = true, }, }

return forms