Module:government: Difference between revisions

From Laenkea
Jump to navigation Jump to search
(Created page with "local export = {} local getArgs = require('Module:Arguments').getArgs -- COLOUR DATA local data = { -- base cases ["nominative"] = {["label"] = "nominative", ["colour"] = "ffb3ba"}, ["accusative"] = {["label"] = "accusative", ["colour"] = "ffdfba"}, ["dative"] = {["label"] = "dative", ["colour"] = "ffffba"}, ["genitive"] = {["label"] = "genitive", ["colour"] = "baffc9"}, ["locative"] = {["label"] = "locative", ["colour"] = "bae1ff"}, ["instrumental"] = {["label"...")
 
No edit summary
Line 12: Line 12:
["locative"] = {["label"] = "locative", ["colour"] = "bae1ff"},
["locative"] = {["label"] = "locative", ["colour"] = "bae1ff"},
["instrumental"] = {["label"] = "instrumental", ["colour"] = "f1b3ff"},
["instrumental"] = {["label"] = "instrumental", ["colour"] = "f1b3ff"},
-- laefevian cases
["illative"] = {["label"] = "illative", ["colour"] = data["locative"].colour},
}
}
-- LAEFEVIAN CASES
data["inessive"] = {["label"] = "inessive", ["colour"] = data["locative"].colour}
data["illative"] = {["label"] = "illative", ["colour"] = data["accusative"].colour}


-- ALIASES
-- ALIASES
Line 26: Line 27:
data["inst"] = data["instrumental"]
data["inst"] = data["instrumental"]
data["ill"] = data["illative"]
data["ill"] = data["illative"]
data["ine"] = data["inessive"]


function export.generate(frame)
function export.generate(frame)

Revision as of 22:24, 26 October 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 = {
	-- base cases
	["nominative"] = {["label"] = "nominative", ["colour"] = "ffb3ba"},
	["accusative"] = {["label"] = "accusative", ["colour"] = "ffdfba"},
	["dative"] = {["label"] = "dative", ["colour"] = "ffffba"},
	["genitive"] = {["label"] = "genitive", ["colour"] = "baffc9"},
	["locative"] = {["label"] = "locative", ["colour"] = "bae1ff"},
	["instrumental"] = {["label"] = "instrumental", ["colour"] = "f1b3ff"},
}

-- LAEFEVIAN CASES
data["inessive"] = {["label"] = "inessive", ["colour"] = data["locative"].colour}
data["illative"] = {["label"] = "illative", ["colour"] = data["accusative"].colour}

-- ALIASES
data["nom"] = data["nominative"]
data["acc"] = data["accusative"]
data["dat"] = data["dative"]
data["gen"] = data["genitive"]
data["loc"] = data["locative"]
data["ins"] = data["instrumental"]
data["inst"] = data["instrumental"]
data["ill"] = data["illative"]
data["ine"] = data["inessive"]

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
	
	if colour then
		return "[<span style=\"background-color: #" .. colour .. ";\">+" .. label .. "</span>]"
	else
		return "[+" .. label .. "]"
	end
end

return export

--[[
Debug console test string:
=p.generate(mw.getCurrentFrame():newChild{title="whatever",args={"accusative"}})
]]