Module:Form of
Appearance
local export = {}
local m_links = require("Module:links")
local declension_tags = {
-- Genders
["m"] = "masculine",
["f"] = "feminine",
["n"] = "neuter",
["c"] = "common",
["s"] = "singular",
["d"] = "dual",
["p"] = "plural",
-- Cases
["abl"] = "ablative",
["acc"] = "accusative",
["com"] = "comitative",
["dat"] = "dative",
["erg"] = "ergative",
["gen"] = "genitive",
["ins"] = "instrumental",
["loc"] = "locative",
["nom"] = "nominative",
["par"] = "partitive",
["prep"] = "prepositional",
["voc"] = "vocative",
}
function format_t(args, iargs, text, term, alt, gloss)
NAMESPACE = mw.title.getCurrentTitle().nsText
local categories = {}
local annotations = {}
local lang = iargs["lang"] or args["lang"]; if lang == "" then lang = nil end
local sc = args["sc"]; if sc == "" then sc = nil end
local id = args["id"]; if id == "" then id = nil end
annotations.gloss = gloss
annotations.tr = args["tr"]; if annotations.tr == "" then annotations.tr = nil end
if not lang then
lang = "en"
table.insert(categories, "Language code missing/form of")
end
lang = require("Module:languages").getLanguageByCode(lang)
if not term then
if NAMESPACE == "Template" then
term = "term"
else
error("You have not given a term to link to.")
end
end
if not text then
error("No definition text provided.")
end
if #categories > 0 then
local m_utilities = require("Module:utilities")
categories = m_utilities.format_categories(categories, lang, nil)
else
categories = ""
end
return
"<span class='form-of-definition'>" .. text .. " of " ..
"<span class='form-of-definition-link'>" .. m_links.full_link(term, alt, lang, sc, "term", id, annotations, nil) .. "</span>" ..
"</span>" .. categories
end
function export.form_of_t(frame)
local args = frame:getParent().args
local iargs = frame.args
local term_param = tonumber(iargs["term_param"]) or 1
local text = iargs[1]; if text == "" then text = nil end
local term = args[term_param]; if term == "" then term = nil end
local alt = args[term_param + 1]; if alt == "" then alt = nil end
local gloss = args[term_param + 2]; if gloss == "" then gloss = nil end
return format_t(args, iargs, text, term, alt, gloss)
end
function export.inflection_t(frame)
local args = frame:getParent().args
local iargs = frame.args
local term = args[1]; if term == "" then term = nil end
local alt = args[2]; if alt == "" then alt = nil end
local gloss = args["gloss"]; if gloss == "" then gloss = nil end
local inflections = {}
local i = 3
local infl = args[i]
while infl do
if infl ~= "" then
table.insert(inflections, declension_tags[infl] or infl)
end
i = i + 1
infl = args[i]
end
return format_t(args, iargs, table.concat(inflections, " "), term, alt, gloss)
end
return export