Module:CharacterInfoboxCitizenship

local CharacterInfoboxCitizenship = {} local HF = require("Module:HF")

local CitizenshipCheck = function( values, table ) local output = "" local valueUpper = "" local valueLower = "" local pagename = tostring(mw.title.getCurrentTitle.text)

for i, value in ipairs( values ) do     if type( value ) ~= nil then valueUpper = HF.firstToUpper( HF.trim( value ) ) valueLower = string.lower( HF.trim( value ) ) if type( table.valid[valueUpper] ) ~= nil and table.valid[valueUpper] == true then output = output .. HF.CategoryLink( valueUpper, pagename, valueUpper ) .. ", "       elseif type( table.substitutes[valueLower] ) == "string" then output = output .. HF.CategoryLink( table.substitutes[valueLower], pagename, valueUpper ) .. ", "       else output = output .. value .. ", "       end else output = output .. value end end

return output end

function CharacterInfoboxCitizenship.main( frame ) local args = frame.args local ctznTable   = require('Module:Citizenship') local citizenships = HF.explode( ",", args.Citizenship) local citizenships2 = HF.explode( ",", args.Citizenship2) local output = "" if not HF.isempty( citizenships ) then output = output .. CitizenshipCheck( citizenships, ctznTable ) end if not HF.isempty( citizenships2 ) then output = output .. CitizenshipCheck( citizenships2, ctznTable ) end if string.sub( output, -2, -1 ) == ", " then output = string.sub( output, 1, -3 ) -- Remove trailing comma and space end if string.sub( output, -1, -1 ) == "," then output = string.sub( output, 1, -2 ) -- Remove trailing comma end return output end

return CharacterInfoboxCitizenship