Module:head: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
No edit summary
Line 21: Line 21:
local args = require("Module:parameters").process(frame:getParent().args, params)
local args = require("Module:parameters").process(frame:getParent().args, params)
local language = require("Module:languages").get_by_code(args[1])
local language = require("Module:languages").get_by_code(args[1])
return "'''" .. args["head"] .. "'''" .. ((args["nocat"] and "") or "[[Category:" .. language.name .. " " .. args[2] .. "s]]")
return "'''" .. args["head"] .. "'''" .. ((args["nocat"] and "") or "[[Category:" .. language.name .. " " .. args[2] .. "s]][[Category:" .. language.name .. " lemmas]]")
end
end


return export
return export

Revision as of 06:50, 6 August 2023

Documentation for this module may be created at Module:head/documentation

local export = {}

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 params = {
		[1] = {required = "true"},
		[2] = {required = "true"},
		["head"] = {default = make_head(mw.title.getCurrentTitle().text)},
		["nocat"] = {type = "boolean"}
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local language = require("Module:languages").get_by_code(args[1])
	return "'''" .. args["head"] .. "'''" .. ((args["nocat"] and "") or "[[Category:" .. language.name .. " " .. args[2] .. "s]][[Category:" .. language.name .. " lemmas]]")
end

return export