Module:UserGenderBox

local p = {} local userboxModule = require('Module:Userbox')

function p.main(frame) local args = frame:getParent.args return p.getBox(args) end

function p.getBox(args) local identifier = (args[1] or args["identifier"]) identifier = (identifier ~= nil and identifier ~= "") and string.lower(identifier) or "?" local gender = args[2] or args["gender"] gender = (gender ~= nil and gender ~= "") and gender or nil -- if gender is empty, set to nil local text = args["text"] text = (text ~= nil and text ~= "") and text or nil -- if text is empty, set to nil local punctuation = args["punctuation"] or "." local genderColor = args["genderColor"] or "inherit"

local logoImage, infoText if identifier == "?" then logoImage = identifier infoText = text or 'This user keeps their ' .. (gender or "gender") .. ' a mystery' .. punctuation elseif identifier == "male" or identifier == "boy" then logoImage = "" infoText = text or 'This user is ' .. (gender or "male") .. ' ' .. punctuation elseif identifier == "female" or identifier == "girl" then logoImage = "" infoText = text or 'This user is ' .. (gender or "female") .. ' ' .. punctuation elseif identifier == "nb" or identifier == "nonbinary" or identifier == "non-binary" then logoImage = "" infoText = text or 'This user is ' .. (gender or "non-binary") .. ' ' .. punctuation elseif identifier == "trans" or identifier == "transgender" then logoImage = "" infoText = text or 'This user is ' .. (gender or "trans") .. ' ' .. punctuation elseif (gender == nil or gender == '') and mw.ustring.find(identifier, '/') then -- assume pronouns usage logoImage = identifier infoText = text or 'This user uses ' .. (identifier or 'no') .. ' pronouns' .. punctuation else logoImage = identifier infoText = text or 'This user is ' .. (gender or identifier) .. ' ' .. punctuation end

-- Set the logo and info text in args before calling Userbox args["id"] = logoImage args["info"] = infoText args["border-c"] = args["border-c"] or "#088A08" args["id-c"] = args["id-c"] or "#D0F5A9" args["info-c"] = args["info-c"] or "#BCF5A9" args["id-s"] = args["id-s"] or 11 return userboxModule.getBox(args) end

return p