پودمان:form of
ظاهر
توضیحات این پودمان میتواند در پودمان:form of/توضیحات قرار گیرد.
local m_links = require("Module:links")
local m_data = mw.loadData("Module:form of/data")
local export = {}
function export.format_t(text, terminfo)
return
"<span class='form-of-definition'>" .. text .. " " ..
"<span class='form-of-definition-link'>" ..
m_links.full_link(terminfo, "term", false) ..
"</span>" ..
"</span>"
end
function export.form_of_t(frame)
local iargs = frame.args
local term_param = tonumber(iargs["term_param"]) or 1
local text = iargs[1]; if text == "" then text = nil end
local lang = iargs["lang"]
local sc = iargs["sc"]
local id = iargs["id"]
local categories = {}
if not text then
error("No definition text provided.")
end
local params = {
[term_param] = {required = true},
[term_param + 1] = {},
[term_param + 2] = {alias_of = "gloss"},
["cap"] = {},
["dot"] = {},
["from"] = {},
["from2"] = {},
["from3"] = {},
["from4"] = {},
["from5"] = {},
["from6"] = {},
["gloss"] = {},
["id"] = {},
["is lemma"] = {type = "boolean"},
["lang"] = {required = lang == nil},
["nocap"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
["nodot"] = {type = "boolean"},
["POS"] = {},
["pos"] = {},
["sc"] = {},
["sort"] = {},
["t"] = {alias_of = "gloss"},
["tr"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local term = args[term_param] or "term"
local alt = args[term_param + 1]
lang = lang or args["lang"] or "und"
sc = sc or args["sc"]
id = id or args["id"]
gloss = args["gloss"] or args["t"]
lang = require("Module:languages").getByCode(lang) or require("Module:languages").err(lang, "lang")
sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
-- add tracking category if term is same as page title
if mw.title.getCurrentTitle().text == lang:makeEntryName(term) then
table.insert(categories, "[[Category:Forms linking to themselves]]")
end
return export.format_t(text, {lang = lang, sc = sc, term = term, alt = alt, id = id, gloss = gloss, tr = args["tr"]}) .. table.concat(categories)
end
function export.tagged_inflections(tags, terminfo)
local cur_infl = {}
local inflections = {}
for i, tag in ipairs(tags) do
if m_data.shortcuts[tag] then
elseif m_data.tags[tag] then
else
require("Module:debug").track{
"inflection of/unknown",
"inflection of/unknown/" .. tag:gsub("%[", "("):gsub("%]", ")"):gsub("|", "!")
}
end
if tag == ";" then
if #cur_infl > 0 then
table.insert(inflections, table.concat(cur_infl, " "))
end
cur_infl = {}
else
tag = m_data.shortcuts[tag] or tag
local data = m_data.tags[tag]
-- If there is a nonempty glossary index, then show a link to it
if data and data.glossary then
tag = "[[Appendix:Glossary#" .. mw.uri.anchorEncode(data.glossary) .. "|" .. tag .. "]]"
end
table.insert(cur_infl, tag)
end
end
if #cur_infl > 0 then
table.insert(inflections, table.concat(cur_infl, " "))
end
if #inflections == 1 then
return export.format_t(inflections[1] .. " of", terminfo)
else
return
"<span class='form-of-definition'>inflection of " ..
"<span class='form-of-definition-link'>" .. m_links.full_link(terminfo, "term", false) .. "</span>" ..
":</span>\n## <span class='form-of-definition'>" .. table.concat(inflections, "</span>\n## <span class='form-of-definition'>") .. "</span>"
end
end
return export