Modul:headword/templates
Seba na module şıma şenê yû pela dokumani vırazê Modul:headword/templates/dok
local export = {}
local b = require("Modul:bases")
-- Part of speech types that should not be pluralized.
local invariable = mw.loadData("Module:headword/data").invariable
function export.head_t(frame)
local plain_param = {}
local list_with_holes = {list = true, allow_holes = true}
local params = {
[1] = {required = true, default = "und"},
["sc"] = plain_param,
["cat sc"] = plain_param,
["sort"] = plain_param,
[2] = {required = true, default = "nouns"},
["noposcat"] = {type = "boolean"},
["nomultiwordcat"] = {type = "boolean", default ="true"},
["nogendercat"] = {type = "boolean"},
["kat2"] = plain_param,
["kat3"] = plain_param,
["kat4"] = plain_param,
["ser"] = {list = true, allow_holes = true, default = ""},
["id"] = plain_param,
["tr"] = list_with_holes,
["ts"] = list_with_holes,
["form"] = list_with_holes,
["c"] = {list = true},
[3] = list_with_holes,
["f=accel-form"] = list_with_holes,
["f=accel-translit"] = list_with_holes,
["f=accel-lemma"] = list_with_holes,
["f=accel-lemma-translit"] = list_with_holes,
["f=accel-gender"] = list_with_holes,
["f=accel-nostore"] = {list = true, allow_holes = true, type = "boolean"},
["f=request"] = list_with_holes,
["f=alt"] = list_with_holes,
["f=sc"] = list_with_holes,
["f=id"] = list_with_holes,
["f=tr"] = list_with_holes,
["f=c"] = list_with_holes,
["f=qual"] = list_with_holes,
["f=nolink"] = {list = true, allow_holes = true, type = "boolean"},
["f=lang"] = list_with_holes,
}
local args = require("Module:parameters").process(frame:getParent().args, params)
-- Get language and script information
local data = {}
data.lang = require("Module:languages").getByCode(args[1]) or require("Module:languages").err(args[1], 1)
data.sort_key = args["sort"]
data.heads = args["ser"]
data.id = args["id"]
data.translits = args["tr"]
data.transcriptions = args["ts"]
data.genders = args["c"]
-- Script
local cat_sc
if args["cat sc"] then
data.sc = (args["cat sc"] and (require("Module:scripts").getByCode(args["cat sc"]) or error("The script code \"" .. args["cat sc"] .. "\" is not valid.")) or nil)
cat_sc = cat_sc
else
data.sc = (args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("The script code \"" .. args["sc"] .. "\" is not valid.")) or nil)
end
-- Part-of-speech category
data.pos_category = args[2]
data.noposcat = args["noposcat"]
if cat_sc then
data.pos_category = data.pos_category .. " in " .. cat_sc:getCategoryName()
end
-- Additional categories
data.categories = {}
data.nomultiwordcat = args["nomultiwordcat"]
data.nogendercat = args["nogendercat"]
if args["kat2"] then
table.insert(data.categories, b.ucfirst(args["kat2"]) .. " be " .. data.lang:getCanonicalName())
end
if args["kat3"] then
table.insert(data.categories, b.ucfirst(args["kat3"]) .. " be " .. data.lang:getCanonicalName())
end
if args["kat4"] then
table.insert(data.categories, b.ucfirst(args["kat4"]) .. " be " .. data.lang:getCanonicalName())
end
-- Inflected forms
data.inflections = {}
for i = 1, math.ceil(args[3].maxindex / 2) do
local infl_part = {
label = args[3][i * 2 - 1],
accel = args["faccel-form"][i] and {
form = args["faccel-form"][i],
translit = args["faccel-translit"][i],
lemma = args["faccel-lemma"][i],
lemma_translit = args["faccel-lemma-translit"][i],
gender = args["faccel-gender"][i],
nostore = args["faccel-nostore"][i],
} or nil,
request = args["frequest"][i],
}
local form = {
term = args[3][i * 2],
alt = args["falt"][i],
genders = {args["fc"][i]},
id = args["fid"][i],
lang = args["flang"][i],
nolink = args["fnolink"][i],
qualifiers = {args["fqual"][i]},
sc = args["fsc"][i],
translit = args["ftr"][i],
}
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[1] then
table.insert(data.inflections[#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:headword").full_headword(data)
end
return export