Module:headword/templates
Appearance
- De neikommende dokumintaasje stiet op Module:headword/templates/dokumintaasje. [bewurkje]
Oernommen fan en:Module:headword/templates.
Oerset:
- wurdsje tekst
- foutmeldingen
- (parten fan) kategorynammen
Oanpast:
- meartal wurdsoarten útskeakele
- wurdsoartnamme út wurdsoartkoade
- parameters fan de taalkopberjochten oars
Taheakke:
- foutmelding 'wurdsoartkoade net jildich'
local export = {}
--[[ n.f.t. - PiefPafPier
-- Part of speech types that should not be pluralized.
local invariable = mw.loadData("Module:headword/data").invariable
--]]
local lemmas = mw.loadData("Module:headword/data").lemmas
local nonlemmas = mw.loadData("Module:headword/data").nonlemmas
function export.head_t(frame)
local plain_param = {}
local list_with_holes = {list = true, allow_holes = true}
local args = {}
local param1 = ""
local param2 = ""
local param3 = {}
-- Oanpassing parameters foar {{#invoke:headword/templates|head_t|<taalkoade>}} yn 'e taalkopberjochten - PiefPafPier
if frame:getParent():getTitle() == "Berjocht:Trefwurd" then
local params = {
[1] = {required = true, default = "und"},
["sc"] = plain_param,
["cat sc"] = plain_param,
["sort"] = plain_param,
[2] = {required = true, default = "subst"},
["cat2"] = plain_param,
["cat3"] = plain_param,
["cat4"] = plain_param,
["head"] = {list = true, allow_holes = true, default = ""},
["id"] = plain_param,
["tr"] = list_with_holes,
-- See also "ts" at bottom.
["g"] = {list = true},
[3] = list_with_holes,
["f=accel"] = list_with_holes,
["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=g"] = list_with_holes,
["f=qual"] = list_with_holes,
["f=nolink"] = {list = true, allow_holes = true, type = "boolean"},
["f=lang"] = list_with_holes,
-- Belongs after "tr", but has to be placed here, or args["falt"] will vanish.
["ts"] = list_with_holes,
}
args = require("Module:parameters").process(frame:getParent().args, params)
param1 = args[1]
param2 = args[2]
param3 = args[3]
else
local params = {
["sc"] = plain_param,
["cat sc"] = plain_param,
["sort"] = plain_param,
[1] = {required = true, default = "subst"},
["cat2"] = plain_param,
["cat3"] = plain_param,
["cat4"] = plain_param,
["head"] = {list = true, allow_holes = true, default = ""},
["id"] = plain_param,
["tr"] = list_with_holes,
-- See also "ts" at bottom.
["g"] = {list = true},
[2] = list_with_holes,
["f=accel"] = list_with_holes,
["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=g"] = list_with_holes,
["f=qual"] = list_with_holes,
["f=nolink"] = {list = true, allow_holes = true, type = "boolean"},
["f=lang"] = list_with_holes,
-- Belongs after "tr", but has to be placed here, or args["falt"] will vanish.
["ts"] = list_with_holes,
-- Parameters fan taalkopberjochten - PiefPafPier
["tref"] = {alias_of = "head"},
["leb"] = {list = true},
["-"] = {},
}
args = require("Module:parameters").process(frame:getParent().args, params)
param1 = frame.args[1]
param2 = args[1]
param3 = args[2]
end
-- Get language and script information
local data = {}
data.lang = require("Module:languages").getByCode(param1) or require("Module:languages").err(param1, 1)
data.sort_key = args["sort"]
data.heads = args["head"]
data.id = args["id"]
data.translits = args["tr"]
data.transcriptions = args["ts"]
data.genders = args["g"]
-- Script
local cat_sc
if args["cat sc"] then
data.sc = (args["cat sc"] and (require("Module:scripts").getByCode(args["cat sc"]) or error("De skriftkoade \"" .. args["cat sc"] .. "\" is net jildich.")) or nil)
cat_sc = cat_sc
else
data.sc = (args["sc"] and (require("Module:scripts").getByCode(args["sc"]) or error("De skriftkoade \"" .. args["sc"] .. "\" is net jildich.")) or nil)
end
-- Part-of-speech category
data.pos_category = lemmas[param2] or nonlemmas[param2] or error("De wurdsoartkoade \"" .. param2 .. "\" is net jildich.")
--[[ n.f.t. - PiefPafPier
if not data.pos_category:find("s$") and not invariable[data.pos_category] then
-- Make the plural form of the part of speech
if data.pos_category:find("x$") then -- prefix, suffix, confix, infix, circumfix, affix, interfix, transfix
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 .. " yn " .. cat_sc:getCategoryName()
end
-- Additional categories
data.categories = {}
if args["cat2"] then
table.insert(data.categories, args["cat2"] .. " yn it " .. data.lang:getCanonicalName())
end
if args["cat3"] then
table.insert(data.categories, args["cat3"] .. " yn it " .. data.lang:getCanonicalName())
end
if args["cat4"] then
table.insert(data.categories, args["cat4"] .. " yn it " .. data.lang:getCanonicalName())
end
-- Inflected forms
data.inflections = {}
for i = 1, math.ceil(param3.maxindex / 2) do
local infl_part = {
label = param3[i * 2 - 1],
accel = args["faccel"][i],
request = args["frequest"][i],
}
local form = {
term = param3[i * 2],
alt = args["falt"][i],
genders = {args["fg"][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("De skriftkoade \"" .. form.sc .. "\" is net jildich.")
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 == "of" 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