Module:government: Difference between revisions
Jump to navigation
Jump to search
TheNightAvl (talk | contribs) mNo edit summary |
TheNightAvl (talk | contribs) mNo edit summary |
||
Line 36: | Line 36: | ||
if args["prep"] then | if args["prep"] then | ||
to_Return = to_Return .. "<i>[[" .. args["prep"] .. "#" .. l_data[args["l"]].name .. "|" .. args["prep"] .. "]]</i> " | to_Return = to_Return .. "+ <i>[[" .. args["prep"] .. "#" .. l_data[args["l"]].name .. "|" .. args["prep"] .. "]]</i> " | ||
end | end | ||
if colour then | if colour then | ||
to_Return = to_Return .. "<span style=\"background-color: #" .. colour .. ";\">+" .. label .. "</span> | to_Return = to_Return .. "<span style=\"background-color: #" .. colour .. ";\">+" .. label .. "</span>" | ||
else | else | ||
to_Return = to_Return .. "+" .. label | to_Return = to_Return .. "+" .. label | ||
end | end | ||
if args["t"] then | |||
to_Return = to_Return .. " = " .. args["t"] | |||
end | |||
to_Return = to_Return .. "]" | |||
if args["l"] and args["pos"] then | if args["l"] and args["pos"] then |
Revision as of 02:30, 10 December 2023
See {{with}}
. To add to the recognised argument list, edit Module:government/data.
local export = {}
local getArgs = require('Module:Arguments').getArgs
-- COLOUR DATA
local data = mw.loadData("Module:government/data")
local l_data = mw.loadData("Module:languages/data")
local function pluralize(word)
local ending = mw.ustring.sub(word, -1)
if ending == "h" and mw.ustring.sub(word, -2, -1) == "s" then ending = "sh" end
if ending == "s" or ending == "z" or ending == "x" or ending == "sh" then
return word .. "es"
end
return word .. "s"
end
function export.generate(frame)
local args = getArgs(frame)
local label = ""
local colour = ""
if not args[1] then
error("First argument required")
end
if data[args[1]] then
label = data[args[1]].label
colour = args[2] or data[args[1]].colour
else
label = args[1]
colour = args[2] or nil
end
local to_Return = "["
if args["prep"] then
to_Return = to_Return .. "+ <i>[[" .. args["prep"] .. "#" .. l_data[args["l"]].name .. "|" .. args["prep"] .. "]]</i> "
end
if colour then
to_Return = to_Return .. "<span style=\"background-color: #" .. colour .. ";\">+" .. label .. "</span>"
else
to_Return = to_Return .. "+" .. label
end
if args["t"] then
to_Return = to_Return .. " = " .. args["t"]
end
to_Return = to_Return .. "]"
if args["l"] and args["pos"] then
to_Return = to_Return .. "[[Category:" .. l_data[args["l"]].name .. " " .. pluralize(args["pos"]) .. " governing the " .. label .. "]]"
end
return to_Return
end
return export
--[[
Debug console test string:
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"accusative"}})
]]