Module:head: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
end | end | ||
local head = args["head"] or make_head(mw.title.getCurrentTitle().text) | local head = args["head"] or make_head(mw.title.getCurrentTitle().text) | ||
return "'''" .. head .. ((args["nocat"] and "") or " | return "'''" .. head .. "'''" .. ((args["nocat"] and "") or "[[Category:" .. language.name .. " " .. pos .. "s]]") | ||
end | end | ||
return export | return export |
Revision as of 23:27, 5 August 2023
Documentation for this module may be created at Module:head/documentation
local export = {}
local get_by_code = require("Module:languages").get_by_code
function export.show(frame)
local function make_head(head)
if not string.find(head, " ") then
return head
end
local pieces = {}
for piece in string.gmatch(head, "%S+") do
table.insert(pieces, "[[" .. piece .. "]]")
end
return table.concat(pieces, " ")
end
local args = (frame:getParent() and frame:getParent().args) or frame.args
local language = get_by_code(args[1])
local pos = args[2] or args["pos"]
if not pos then
error("Part of speech must be supplied")
end
local head = args["head"] or make_head(mw.title.getCurrentTitle().text)
return "'''" .. head .. "'''" .. ((args["nocat"] and "") or "[[Category:" .. language.name .. " " .. pos .. "s]]")
end
return export