local export = {}
-- Part of speech types that should not be pluralized.
local invariable = mw.loadData("Module:headword/data").invariable
function export.head_t(frame)
local params = {
= {required = true, default = "und"},
= {},
= {},
= {},
= {required = true, default = "nouns"},
= {},
= {},
= {},
= {list = true, allow_holes = true, default = ""},
= {},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true},
= {list = true, allow_holes = true, type = "boolean"},
= {list = true, allow_holes = true},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
-- Get language and script information
local data = {}
data.lang = require("Module:languages").getByCode(args) or require("Module:languages").err(args, 1)
data.sort_key = args
data.heads = args
data.id = args
data.translits = args
data.transcripts = args
data.genders = args
-- Script
local cat_sc
if args then
data.sc = (args and (require("Module:scripts").getByCode(args) or error("The script code \"" .. args .. "\" is not valid.")) or nil)
cat_sc = cat_sc
else
data.sc = (args and (require("Module:scripts").getByCode(args) or error("The script code \"" .. args .. "\" is not valid.")) or nil)
end
-- Part-of-speech category
data.pos_category = args
if not data.pos_category:find("s$") and not invariable then
-- Make the plural form of the part of speech
if data.pos_category:find("x$") then
data.pos_category = data.pos_category .. "es"
else
data.pos_category = data.pos_category .. "s"
end
end
if cat_sc then
data.pos_category = data.pos_category .. " in " .. cat_sc:getCategoryName()
end
-- Additional categories
data.categories = {}
if args then
table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args)
end
if args then
table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args)
end
if args then
table.insert(data.categories, data.lang:getCanonicalName() .. " " .. args)
end
-- Inflected forms
data.inflections = {}
for i = 1, math.ceil(args.maxindex / 2) do
local infl_part = {
label = args,
accel = args,
request = args,
}
local form = {
term = args,
alt = args,
genders = {args},
id = args,
lang = args,
nolink = args,
qualifiers = {args},
sc = args,
translit = args,
transcript = args,
}
if form.lang then
form.lang = require("Module:languages").getByCode(form.lang) or require("Module:languages").err(form.lang, "f" .. i .. "lang")
end
if form.sc then
form.sc = require("Module:scripts").getByCode(form.sc) or error("The script code \"" .. form.sc .. "\" is not valid.")
end
-- If no term or alt is given, then the label is shown alone.
if form.term or form.alt then
table.insert(infl_part, form)
end
if infl_part.label == "or" then
-- Append to the previous inflection part, if one exists
if #infl_part > 0 and data.inflections then
table.insert(data.inflections, form)
end
elseif infl_part.label then
-- Add a new inflection part
table.insert(data.inflections, infl_part)
end
end
return require("Module:User:Victar/headword").full_headword(data)
end
return export