Modul:sjn-headword
Bu modul uchun Modul:sjn-headword/doc nomli hujjat sahifasini yaratishingiz mumkin
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("sjn")
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, "Sindarin " .. args["cat2"])
end
if args["cat3"] then
table.insert(data.categories, "Sindarin " .. args["cat3"])
end
handle_infl(args, data, "stem", "stem")
if pos_functions[poscat] then
pos_functions[poscat](args, data)
end
local phon = args["teng"] or args["phon"] or args["head"] or PAGENAME -- detects only first one
local tengw = tengwar.convert("sjn", "annatar", phon)
data.heads[1] = data.heads[1]..' • <span style="'..twstyle..'">'..tengw..'</span>'
return require("Module:headword").full_headword(data)
end
pos_functions["adjectives"] = function(args, data)
handle_infl(args, data, "pl", "plural")
end
pos_functions["nouns"] = function(args, data)
handle_infl(args, data, "du", "dual")
handle_infl(args, data, "pl", "plural")
end
pos_functions["verbs"] = function(args, data)
handle_infl(args, data, "past", "past tense")
end
pos_functions["proper nouns"] = pos_functions["nouns"]
return export