Module:coinage: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
local function format_coinage(name, alt_name, coined_in, coiner_nat, coiner_occ, coined_at) | local function format_coinage(name, alt_name, coined_in, coiner_nat, coiner_occ, coined_at) | ||
local out = name or alt_name or "" | local out = name or alt_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 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_occ then out = coiner_occ .. (#out > 0 and (" " .. out) or "") end | ||
if coiner_nat then out = coiner_nat .. (#out > 0 and (" " .. out) or "") end | if coiner_nat then out = coiner_nat .. (#out > 0 and (" " .. out) or "") end | ||
return out | return out | ||
end | end |
Revision as of 11:41, 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 = name or alt_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