Modul:mn-verb-form
Qiyofa
Bu modul uchun Modul:mn-verb-form/doc nomli hujjat sahifasini yaratishingiz mumkin
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 = {
[1] = {required = true, default = "suffix"}, --suffix
[2] = {required = true, default = "term"}, --verb
[3] = {},
[4] = {alias_of = "gloss"},
["dot"] = {},
["gloss"] = {},
["t"] = {alias_of = "gloss"},
["id"] = {},
["nodot"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
["sc"] = {},
["tr"] = {},
["sort_key"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local sc = (args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. args["sc"] .. "\" is not valid.")) or nil)
local suffix = args[1]
local text = ""
local alias = false
if data.aliases[args[1]] then
alias = true
suffix = data.aliases[args[1]]
end
if data.suffix[suffix] then
local suffixinfo = {lang = lang, sc = sc, term = "-"..suffix, alt = alias and "-" .. args[1], id = "verb suffix"}
local suffixlink = m_links.full_link(suffixinfo, "term", false)
text = data.suffix[suffix].name .. " in " .. suffixlink .. " of"
else
error("suffix not found")
end
local lemma_obj = {lang = lang, sc = sc, term = args[2], alt = args[3], id = args["id"], gloss = args["gloss"], tr = args["tr"]}
return require("Module:form of").format_form_of{text = text, lemmas = {lemma_obj}, lemma_face = "term"} .. (args.nocat and "" or show_categories(data.suffix[suffix], lang, args["sort_key"]))
end
function export.mn_suffix_name(frame)
local params = {
[1] = {required = true, default = "suffix"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local suffix = args[1]
if data.aliases[suffix] then
suffix = data.aliases[suffix]
end
if data.suffix[suffix] then
return data.suffix[suffix].name
else
error("suffix not found")
end
end
return export