Module:qya-headword
Jump to navigation
Jump to search
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local pos_functions = {}
local twstyle = "font-family: 'Tengwar Annatar', 'Tengwar Eldamar', 'Tengwar Noldor', 'Tengwar Parmaite', 'Tengwar Formal', 'Tengwar Elfica', 'Tengwar Sindarin', 'Tengwar Quenya', 'Tengwar Gothika'"
-- If Not Empty
local function ine(arg)
if arg == "" then
return nil
else
return arg
end
end
local function handle_infl(args, data, argpref, label)
if args[argpref] and args[argpref..'2'] then
local forms = {}
local form = argpref
local i = 1
while args[form] do
table.insert (forms, args[form])
i = i + 1
form = argpref..i
end
forms.label = mw.ustring.gsub(label, 'form', 'forms')
table.insert(data.inflections, forms )
elseif args[argpref] then
table.insert(data.inflections, { label = label, args[argpref]})
end
end
local lang = require("Module:languages").getByCode("qya")
local script = require('Module:scripts').getByCode("Latn")
local PAGENAME = mw.ustring.gsub(mw.title.getCurrentTitle().text, '[^/]+/', '')
local tengwar = require("Module:tengwar")
function export.show(frame)
local args = frame:getParent().args
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
poscat = string.gsub(poscat, 'form', 'forms')
local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = {args["head"] or PAGENAME}, inflections = {}, sort_key = args["sort"]}
if args["cat2"] then
table.insert(data.categories, "Quenya " .. args["cat2"])
end
if args["cat3"] then
table.insert(data.categories, "Quenya " .. args["cat3"])
end
handle_infl(args, data, "stem", "stem")
if pos_functions[poscat] then
pos_functions[poscat](args, data)
end
local tengw = tengwar.convert("qya", "annatar", args["teng"] or args["phon"] or args["head"] or PAGENAME)
data.heads[1] = data.heads[1]..' • <span style="'..twstyle..'">'..tengw..'</span>'
return require("Module:headword").full_headword(data)
end
pos_functions["nouns"] = function(args, data)
handle_infl(args, data, "du", "dual")
handle_infl(args, data, "pl", "plural")
end
pos_functions["pronouns"] = function(args, data)
handle_infl(args, data, "encl", "enclitic form")
handle_infl(args, data, "ind", "independent form")
handle_infl(args, data, "emph", "emphatic form")
end
pos_functions["verbs"] = function(args, data)
handle_infl(args, data, "past", "past tense")
end
pos_functions["proper nouns"] = pos_functions["nouns"]
return export