Module:kilta-headword: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 3: Line 3:
local gsub = mw.ustring.gsub
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local sub = mw.ustring.sub
local split = mw.ustring.split


local TILDEB = u(0x0330) -- COMBINING TILDE BELOW ̰◌
local TILDEB = u(0x0330) -- COMBINING TILDE BELOW ̰◌
Line 37: Line 38:
["pl"] = {list = true},
["pl"] = {list = true},
["w"] = {default = mw.title.getCurrentTitle().text},
["w"] = {default = mw.title.getCurrentTitle().text},
["n"] = {type = number}
}
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local args = require("Module:parameters").process(frame:getParent().args, params)
local word = args["w"]
local word = args.w
local pos = args[1]; local pl = args["pl"]
local pos = args[1]; local pl = args.pl
local data = {lang = lang, pos_category = deabb[pos], heads = {word}, categories = {}, inflections = {},}
local data = {lang = lang, pos_category = deabb[pos], heads = {word}, categories = {}, inflections = {},}
local w = split(word, "[^%s]*")
if pl[1] == '-' then
if pl[1] == '-' then
Line 57: Line 61:
table.insert(data.inflections, pl)
table.insert(data.inflections, pl)
else
else
table.insert(data.inflections, plural(word))
table.insert(data.inflections, plural(#w > 1 and w[args.n] or word))
end
end
end
end