Module:tln-headword: Difference between revisions
Created page with "local p = {} function p.noun(frame) local args = frame:getParent().args local title = mw.title.getCurrentTitle().text local g = args.g or "?" local rom = args.rom or "" local pl = args.pl or "" local plrom = args.plrom or "" local text = "'''" .. title .. "'''" if rom ~= "" then text = text .. " • (" .. rom .. ")" end text = text .. " " .. g if pl ~= "" then text = text .. ", plural '''" .. pl .. "'''"..." |
mNo edit summary |
||
| Line 1: | Line 1: | ||
local | local export = {} | ||
local pos_functions = {} | |||
local lang = require("Module:languages").getByCode("tln") | |||
local PAGENAME = mw.title.getCurrentTitle().text | |||
-- Nouns | |||
pos_functions.nouns = function(class, args, data) | |||
local params = { | |||
[1] = {required = true}, -- gender | |||
["pl"] = {}, | |||
["head"] = {}, | |||
["tr"] = {}, | |||
["pltr"] = {}, | |||
} | |||
local args = require("Module:parameters").process(args, params) | |||
local head = args.head or PAGENAME | |||
data.lang = lang | |||
data.heads = {head} | |||
data.genders = {args[1]} | |||
data.inflections = {} | |||
-- plural handling | |||
if args.pl then | |||
local infl = { | |||
label = "plural", | |||
{ term = args.pl } | |||
} | |||
if args.pltr then | |||
infl[1].tr = args.pltr | |||
end | |||
table.insert(data.inflections, infl) | |||
end | |||
if args.tr then | |||
data.translits = {args.tr} | |||
end | |||
end | end | ||
return | -- Entry point | ||
function export.show(frame) | |||
local parent_args = frame:getParent().args | |||
local poscat = frame.args[1] or "nouns" | |||
local data = { | |||
inflections = {}, | |||
genders = {}, | |||
categories = {}, | |||
} | |||
if pos_functions[poscat] then | |||
pos_functions[poscat](nil, parent_args, data) | |||
end | |||
return require("Module:headword").full_headword(data) | |||
end | |||
return export | |||