Module:head/languages: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
local default_params = { | local default_params = { | ||
["gender"] = {list = true, aliases = {"g", 1}}, | ["gender"] = {list = true, aliases = {"g", 1}}, | ||
["label"] = {list = true, aliases = {"l"}}, | |||
["head"] = {}, | ["head"] = {}, | ||
} | } | ||
Line 43: | Line 44: | ||
pos = pos, | pos = pos, | ||
genders = args["gender"], | genders = args["gender"], | ||
labels = args["label"], | |||
inflections = inflections, | inflections = inflections, | ||
} | } |
Revision as of 11:38, 12 August 2023
Documentation for this module may be created at Module:head/languages/documentation
local export = {}
local m_head = require("Module:head")
local m_languages = require("Module:languages")
local default_params = {
["gender"] = {list = true, aliases = {"g", 1}},
["label"] = {list = true, aliases = {"l"}},
["head"] = {},
}
function export.get_args(args, params, inflection_params)
if inflection_params then
for _, v in ipairs(inflection_params) do
params[v.param] = {list = true}
end
end
local p = require("Module:parameters").process(args, params)
local inflections = {}
if inflection_params then
for _, v in ipairs(inflection_params) do
local inflection = p[v.param]
inflection["label"] = v.label
inflection["glossary"] = v.glossary
table.insert(inflections, inflection)
end
end
return p, inflections
end
function export.get_term()
return mw.title.getCurrentTitle().text
end
function export.show(frame)
local language = m_languages.get_by_code(frame.args[1])
local pos = frame.args[2]
local inflection_params = mw.loadData("Module:head/languages/" .. language.code)
local args, inflections = export.get_args(frame:getParent().args, default_params, inflection_params[pos])
return m_head.full_head{
term = mw.title.getCurrentTitle().text,
head = args["head"],
language = language,
pos = pos,
genders = args["gender"],
labels = args["label"],
inflections = inflections,
}
end
return export