Module:coinage: Difference between revisions

From Laenkea
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
[1] = {required = true},
[1] = {required = true},
[2] = {},
[2] = {},
[3] = {},
["alt"] = {alias_of = 3},
["in"] = {},
["in"] = {},
["nationality"] = {},
["n"] = {alias_of = "nationality"},
["nat"] = {alias_of = "nationality"},
["occupation"] = {},
["o"] = {alias_of = "occupation"},
["occ"] = {alias_of = "occupation"},
["at"] = {},
["nocap"] = {type = "boolean"},
["nocap"] = {type = "boolean"},
["notext"] = {type = "boolean"},
["notext"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
["nocat"] = {type = "boolean"},
}
}
local function format_coinage(name, alt_name, coined_in, coiner_nat, coiner_occ, coined_at)
local out = alt_name or name or ""
if coined_at then out = out .. (#out > 0 and " " or "") .. "at " .. coined_at end
if coined_in then out = out .. (#out > 0 and " " or "") .. "in " .. coined_in end
if coiner_occ then out = coiner_occ .. (#out > 0 and (" " .. out) or "") end
if coiner_nat then out = coiner_nat .. (#out > 0 and (" " .. out) or "") end
return out
end
function export.show(frame)
function export.show(frame)
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])
local out = ""
local out = format_coinage(args[2], args[3], args["in"], args["nationality"], args["occupation"], args["at"])
if not args["notext"] then
if not args["notext"] then
out = out .. "[[Appendix:Glossary#coinage|" .. (args["nocap"] and "c" or "C") .. "oined]]" .. (args[2] and " by " or "")
out = "[[Appendix:Glossary#coinage|" .. (args["nocap"] and "c" or "C") .. "oined]]" .. (#out > 0 and " by " or "") .. out
end
if not args["nocat"] then
out = out .. "[[Category:" .. language.name .. " coinages]]"
if args[2] and #args[2] > 0 then
out = out .. "[[Category:" .. language.name .. " terms coined by " .. args[2] .. "]]"
end
end
end
if args[2] then out = out .. args[2] end
if args["in"] then out = out .. " in " .. args["in"] end
if not args["nocat"] then out = out .. "[[Category:" .. language.name .. " coinages]]" end
return out
return out
end
end
return export
return export

Latest revision as of 11:46, 27 February 2024

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

local export = {}
local params = {
	[1] = {required = true},
	[2] = {},
	[3] = {},
	["alt"] = {alias_of = 3},
	["in"] = {},
	["nationality"] = {},
	["n"] = {alias_of = "nationality"},
	["nat"] = {alias_of = "nationality"},
	["occupation"] = {},
	["o"] = {alias_of = "occupation"},
	["occ"] = {alias_of = "occupation"},
	["at"] = {},
	["nocap"] = {type = "boolean"},
	["notext"] = {type = "boolean"},
	["nocat"] = {type = "boolean"},
}

local function format_coinage(name, alt_name, coined_in, coiner_nat, coiner_occ, coined_at)
	local out = alt_name or name or ""
	if coined_at then out = out .. (#out > 0 and " " or "") .. "at " .. coined_at end
	if coined_in then out = out .. (#out > 0 and " " or "") .. "in " .. coined_in end
	if coiner_occ then out = coiner_occ .. (#out > 0 and (" " .. out) or "") end
	if coiner_nat then out = coiner_nat .. (#out > 0 and (" " .. out) or "") end
	return out
end

function export.show(frame)
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local language = require("Module:languages").get_by_code(args[1])
	local out = format_coinage(args[2], args[3], args["in"], args["nationality"], args["occupation"], args["at"])
	if not args["notext"] then
		out = "[[Appendix:Glossary#coinage|" .. (args["nocap"] and "c" or "C") .. "oined]]" .. (#out > 0 and " by " or "") .. out
	end
	if not args["nocat"] then
		out = out .. "[[Category:" .. language.name .. " coinages]]"
		if args[2] and #args[2] > 0 then
			out = out .. "[[Category:" .. language.name .. " terms coined by " .. args[2] .. "]]"
		end
	end
	return out
end

return export