This module implements the {{mn-verb form of}}
and the {{mn-verb form name}}
templates. To add more suffixes, edit Module:mn-verb-form/data.
local export = {}
local m_links = require("Module:links")
local m_utilities = require("Module:utilities")
local lang = require("Module:languages").getByCode("mn")
local data = mw.loadData("Module:mn-verb-form/data")
local function show_categories(data, lang, sort_key)
local categories = {}
for i, cat in ipairs(data.categories or {}) do
table.insert(categories, lang:getCanonicalName() .. " " .. cat)
end
return m_utilities.format_categories(categories, lang, sort_key)
end
function export.mn_verb_form(frame)
local params = {
= {required = true, default = "suffix"}, --suffix
= {required = true, default = "term"}, --verb
= {},
= {alias_of = "gloss"},
= {},
= {},
= {alias_of = "gloss"},
= {},
= {type = "boolean"},
= {type = "boolean"},
= {},
= {},
= {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local sc = (args and (require("Module:scripts").getByCode(args) or error("The script code \"" .. args .. "\" is not valid.")) or nil)
local suffix = args
local text = ""
local alias = false
if data.aliases] then
alias = true
suffix = data.aliases]
end
if data.suffix then
local suffixinfo = {lang = lang, sc = sc, term = "-"..suffix, alt = alias and "-" .. args, id = "verb suffix"}
local suffixlink = m_links.full_link(suffixinfo, "term", false)
text = data.suffix.name .. " in " .. suffixlink .. " of"
else
error("suffix not found")
end
local lemma_obj = {lang = lang, sc = sc, term = args, alt = args, id = args, gloss = args, tr = args}
return require("Module:form of").format_form_of{text = text, lemmas = {lemma_obj}, lemma_face = "term"} .. (args.nocat and "" or show_categories(data.suffix, lang, args))
end
function export.mn_suffix_name(frame)
local params = {
= {required = true, default = "suffix"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local suffix = args
if data.aliases then
suffix = data.aliases
end
if data.suffix then
return data.suffix.name
else
error("suffix not found")
end
end
return export