FANDOM


local valid = {
  ["Abysmian"] = "Abysmians",
  ["Afghani"] = "Afghans",
  ["African"] = "Africans",
  ["American"] = "Americans",
  ["Amerikan"] = "Amerikans",
  ["Amazon"] = "Amazons",
  ["Angolan"] = "Angolans",
  ["Apokoliptian"] = "Apokoliptians",
  ["Argentinian"] = "Argentinians",
  ["Armenian"] = "Armenians",
  ["Asgardian"] = "Asgardians",
  ["Atlantean"] = "Atlanteans",
  ["Attilan"] = "Attilans",
  ["Australian"] = "Australians",
  ["Austrian"] = "Austrians",
  ["Azanian"] = "Azanians",
  ["Aztek"] = "Azteks",
  ["Balkan"] = "Balkans",
  ["Belarusian"] = "Belarusians",
  ["Belgian"] = "Belgians",
  ["Bessarovian"] = "Bessarovians",
  ["Bhutranian"] = "Bhutranians",
  ["Bialyan"] = "Bialyans",
  ["Bolivian"] = "Bolivians",
  ["Borgonian"] = "Borgonians",
  ["Bosnian"] = "Bosnians",
  ["Brazilian"] = "Brazilians",
  ["British"] = "Brits",
  ["Buredunian"] = "Buredunians",
  ["Cambodian"] = "Cambodians",
  ["Canaanite"] = "Canaanites",
  ["Canadian"] = "Canadians",
  ["Carib"] = "Caribs",
  ["Chilean"] = "Chileans",
  ["Chinese"] = "Chinese",
  ["Colombian"] = "Colombians",
  ["Congolese"] = "Congolese",
  ["Cooperative"] = "Cooperative",
  ["Corto Maltesian"] = "Corto Maltesians",
  ["Costa Verdean"] = "Costa Verdeans",
  ["Croatoan"] = "Croatoans",
  ["Cuban"] = "Cubans",
  ["Czechoslovakian"] = "Czechoslovakians",
  ["Danish"] = "Danes",
  ["Delanzan"] = "Delanzans",
  ["Delvadian"] = "Delvadians",
  ["Dherainian"] = "Dherainian",
  ["Diabloverdan"] = "Diabloverdans",
  ["Dominican"] = "Dominicans",
  ["Dutch"] = "Dutch",
  ["Egyptian"] = "Egyptians",
  ["English"] = "English",
  ["Eternal"] = "Eternals",
  ["Ethiopian"] = "Ethiopians",
  ["European"] = "Europeans",
  ["Feitheran"] = "Feitherans",
  ["Filipino"] = "Filipinos",
  ["Finnish"] = "Fins",
  ["French"] = "French",
  ["Gamorran"] = "Gamorrans",
  ["Gardevian"] = "Gardevians",
  ["Genesisian"] = "Genesisians",
  ["Georgian"] = "Georgians",
  ["German"] = "Germans",
  ["Ghanaian"] = "Ghanaians",
  ["Ghudazan"] = "Ghudazans",
  ["Gorilla City Citizen"] = "Gorilla City Citizens",
  ["Greek"] = "Greeks",
  ["Guatemalan"] = "Guatemalans",
  ["Haitian"] = "Haitians",
  ["Hasaraguan"] = "Hasaraguans",
  ["Hawaiian"] = "Hawaiians",
  ["Hellion"] = "Hellions",
  ["Hungarian"] = "Hungarians",
  ["Hun"] = "Huns",
  ["Icelandic"] = "Icelanders",
  ["Idylist"] = "Idylists",
  ["Ilandian"] = "Ilandians",
  ["Indian"] = "Indians",
  ["Indonesian"] = "Indonesians",
  ["Inniversian"] = "Inniversians",
  ["Iranian"] = "Iranians",
  ["Iraqi"] = "Iraqis",
  ["Irish"] = "Irish",
  ["Israeli"] = "Israelis",
  ["Israelite"] = "Israelites",
  ["Italian"] = "Italians",
  ["Jalibian"] = "Jalibians",
  ["Jamaican"] = "Jamaicans",
  ["Japanese"] = "Japanese",
  ["Jarhanpurian"] = "Jarhanpurians",
  ["Kandorian"] = "Kandorians",
  ["Karlovnan"] = "Karlovnans",
  ["Kaznian"] = "Kaznians",
  ["Kenyan"] = "Kenyans",
  ["Kahndaqi"] = "Kahndaqis",
  ["Korean"] = "Koreans",
  ["Koran"] = "Korans",
  ["Kravian"] = "Kravians",
  ["K'un-L'unan"] = "K'un-L'unans",
  ["Laotian"] = "Laotians",
  ["Latkovian"] = "Latkovians",
  ["Latverian"] = "Latverians",
  ["Libyan"] = "Libyans",
  ["Lithuanian"] = "Lithuanians",
  ["M'Changan"] = "M'Changans",
  ["Macedonian"] = "Macedonians",
  ["Malaysian"] = "Malaysians",
  ["Markovian"] = "Markovians",
  ["Mayan"] = "Mayans",
  ["Mbangawian"] = "Mbangawians",
  ["Mexican"] = "Mexicans",
  ["Modoran"] = "Modorans",
  ["Mongolian"] = "Mongols",
  ["Mordanian"] = "Mordanians",
  ["Morlaidhan"] = "Morlaidhans",
  ["Moroccan"] = "Moroccans",
  ["Morovian"] = "Morovians",
  ["Mtamban"] = "Mtambans",
  ["Muvian"] = "Muvians",
  ["Narobian"] = "Narobians",
  ["Native American"] = "Native Americans",
  ["Neosian"] = "Neosians",
  ["Nestralian"] = "Nestralians",
  ["New Canaanite"] = "New Canaanites",
  ["New Zealander"] = "New Zealanders",
  ["Nicaraguan"] = "Nicaraguans",
  ["Nigerian"] = "Nigerians",
  ["North American"] = "North Americans",
  ["North Korean"] = "North Koreans",
  ["Norwegian"] = "Norwegians",
  ["Nova Roman"] = "Nova Romans",
  ["Oan"] = "Oans",
  ["Olympian"] = "Gods of Olympus",
  ["Oteroan"] = "Oteroans",
  ["Pakistani"] = "Pakistanis",
  ["Palestinian"] = "Palestinians",
  ["Peruvian"] = "Peruvians",
  ["Pokolistani"] = "Pokols",
  ["Polish"] = "Poles",
  ["Polynesian"] = "Polynesians",
  ["Puerto Rican"] = "Puerto Ricans",
  ["Pyromanian"] = "Pyromanians",
  ["Quraci"] = "Quracis",
  ["Ramistani"] = "Ramistanis",
  ["Rimborian"] = "Rimborians",
  ["Roman"] = "Romans",
  ["Romanian"] = "Romanians",
  ["Romiroan"] = "Romiroans",
  ["Russian"] = "Russians",
  ["Samoan"] = "Samoans",
  ["San Diabloan"] = "San Diabloans",
  ["Santa Priscan"] = "Santa Priscans",
  ["Saudi Arabian"] = "Saudi Arabians",
  ["Scandinavian"] = "Scandinavians",
  ["Scottish"] = "Scots",
  ["Skartarian"] = "Skartarians",
  ["Sligs"] = "Sligs",
  ["Slorenian"] = "Slorenians",
  ["Solarian"] = "Solarians",
  ["Somalian"] = "Somalians",
  ["South African"] = "South Africans",
  ["South Korean"] = "South Koreans",
  ["Soviet"] = "Soviets",
  ["Spanish"] = "Spanish",
  ["Swedish"] = "Swedes",
  ["Swiss"] = "Swiss",
  ["Sudanese"] = "Sudanese",
  ["Symkarian"] = "Symkarians",
  ["Syrian"] = "Syrians",
  ["Taiwanese"] = "Taiwanese",
  ["Thai"] = "Thais",
  ["Tibetan"] = "Tibetans",
  ["Tierra Verdean"] = "Tierra Verdeans",
  ["Trans-Sabalian"] = "Trans-Sabalians",
  ["Transbelvan"] = "Transbelvans",
  ["Transian"] = "Transians",
  ["Transylvanian"] = "Transylvanians",
  ["Trezygstani"] = "Trezygstanis",
  ["Trojan"] = "Trojans",
  ["Tropidoran"] = "Tropidorans",
  ["Tynandan"] = "Tynandans",
  ["Tundan"] = "Tundans",
  ["Tunisian"] = "Tunisians",
  ["Turkish"] = "Turks",
  ["Ugandan"] = "Ugandans",
  ["Ukrainian"] = "Ukrainians",
  ["United Planets Citizen"] = "United Planets Citizens",
  ["Venegerian"] = "Venegerians",
  ["Venezuelan"] = "Venezuelans",
  ["Vietnamese"] = "Vietnamese",
  ["Viking"] = "Vikings",
  ["Vlatavan"] = "Vlatavans",
  ["Wakandan"] = "Wakandans",
  ["Welsh"] = "Welsh",
  ["Wild Lander"] = "Wild Landers",
  ["Xebelian"] = "Xebelians",
  ["Xibalban"] = "Xibalbans",
  ["Yemeni"] = "Yemenis",
  ["Yugoslavian"] = "Yugoslavs",
  ["Zambesian"] = "Zambesians",
  ["Zambian"] = "Zambians",
  ["Zandian"] = "Zandians",
  ["Zanzibari"] ="Zanzibaris",
  ["Zenoshan"] = "Zenoshans",
  ["Zoranian"] = "Zoranians",
 
}
 
 
local substitutes = {
    ["abysmia"] = "Abysmian",
    ["afghan"] = "Afghani",
    ["africa"] = "African",
    ["albania"] = "Albanian",
    ["america"] = "American",
    ["amerika"] = "Amerikan",
    ["amazon"] = "Amazon",
    ["amazonian"] = "Amazon",
    ["angola"] = "Angolan",
    ["apokolips"] = "Apokoliptian",
    ["argentina"] = "Argentinian",
    ["armenia"] = "Armenian",
    ["asia"] = "Asian",
    ["asian american"] = "American",
    ["asian-american"] = "American",
    ["asgard"] = "Asgardian",
    ["atlantis"] = "Atlantean",
    ["attilan"] = "Attilan",
    ["austanburg"] = "Austanburger",
    ["austrailia"] = "Australian",
    ["austria"] = "Austrian",
    ["azania"] = "Azanian",
    ["aztek civilization"] = "Aztek",
    ["britain"] = "British",
    ["brits"] = "British",
    ["great britain"] = "British",
    ["balkan"] = "Balkan",
    ["belrusia"] = "Belarusian",
    ["bessarovia"] = "Bessarovian",
    ["bialyan"] = "bialyan",
    ["belgium"] = "Belgian",
    ["bolivia"] = "Bolivian",
    ["borgonia"] = "Borgonian",
    ["bosnia"] = "Bosnian",
    ["bosnia and herzgovina"] = "Bosnian",
    ["brazil"] = "Brazilian",
    ["buredunia"] = "Buredunian",
    ["cambodia"] = "Cambodian",
    ["canaan"] = "Canaanite",
    ["canada"] = "Canadian",
    ["carib"] = "Carib",
    ["caribbean"] = "Carib",
    ["chile"] = "Chilean",
    ["china"] = "Chinese",
    ["colombia"] = "Colombian",
    ["congo"] = "Congolese",
    ["democratic republic of the congo"] = "Congolese", 
    ["republic of the congo"] = "Congolese",
    ["cooperative"] = "Cooperative",
    ["corto maltese"] = "Corto Maltesian",
    ["costa verde"] = "Costa Verdean",
    ["croatoa"] = "Croatoan",
    ["cuba"] = "Cuban",
    ["czechoslovakia"] = "Czechoslovakian",
    ["danish"] = "Danish",
    ["delanza"] = "Delanzan",
    ["denmark"] = "Danish",
    ["delvadia"] = "Delvadian",
    ["dherain"] = "Dherainian",
    ["the dominican republic"] = "Dominican",
    ["dominican republic"] = "Dominican",
    ["egypt"] = "Egyptian",
    ["england"] = "English",
    ["eternals"] = "Eternal",
    ["eternal"] = "Eternal",
    ["europe"] = "European",
    ["ethopia"] = "Ethiopian",
    ["feithera"] = "Feitheran",
    ["feitheran"] = "Feitheran",
    ["finnish"] = "Finnish",
    ["finland"] = "Finnish",
    ["french"] = "French",
    ["france"] = "French",
    ["united kingdom"] = "British",
    ["brit"] = "British",
    ["great britain"] = "British",
    ["gamorra"] = "Gamorran",
    ["gardevia"] = "Gardevian",
    ["new genesis"] = "Genisisian",
    ["georgia"] = "Georgian",
    ["georgia (asia)"] = "Georgian",
    ["germany"] = "German",
    ["ghana"] = "Ghanaian",
    ["ghudaza"] = "Ghudazan",
    ["gorilla city"] = "Gorilla City Citizen",
    ["greece"] = "Greek",
    ["guatemala"] = "Guatemalan",
    ["haiti"] = "Haitian",
    ["hasaragua"] = "Hasaraguan",
    ["hawaii"] = "Hawaiian",
    ["hell"] = "Hellion",
    ["holland"] = "Dutch",
    ["hungary"] = "Hungarian",
    ["hunnic empire"] = "Huns",
    ["iceland"] = "Icelandic",
    ["shayeris"] = "Idylist",
    ["ilandia"] = "Ilandian",
    ["india"] = "Indian",
    ["indonesia"] = "Indonesian",
    ["iran"] = "Iranian",
    ["iraq"] = "Iraqi",
    ["ireland"] = "Irish",
    ["israel"] = "Israeli",
    ["italy"] = "Italian",
    ["republic of jalib"] = "Jalibian",
    ["jamaica"] = "Jamaican",
    ["japan"] = "Japanese",
    ["jarhanpur"] = "Jarhanpurian",
    ["kahndaq"] = "Kahndaqi",
    ["karlovna"] = "Karlovnan",
    ["korans"] = "Koran",
    ["kandor"] = "Kandorian",
    ["kaznia"] = "Kaznian",
    ["korea"] = "Korean",
    ["kenyan"] = "Kenyan",
    ["kenyans"] = "Kenyan",
    ["kenya"] = "Kenyan",
    ["kingdom of israel"] = "Israelite",
    ["kravia"] = "Kravian",
    ["laos"] = "Laotian",
    ["latkovia"] = "Latkovian",
    ["latkovia (amalgam universe)"] = "Latkovian",
    ["latveria"] = "Latverian",
    ["libya"] = "Libyan",
    ["lithuania"] = "Lithuanian",
    ["m'changa"] = "M'Changan",
    ["macedonia"] = "Macedonian",
    ["malaysian"] = "Malaysian",
    ["markovia"] = "Markovian",
    ["markovians"] = "Markovian",
    ["mayan civilization"] = "Mayan",
    ["mbanangawi"] = "Mbangawian",
    ["mexico"] = "Mexican",
    ["mexicans"] = "Mexican",
    ["modorans"] = "Modoran",
    ["modora"] = "Modoran",
    ["morlaidh"] = "Morlaidhan",
    ["mongolia"] = "Mongolian",
    ["mongolians"] = "Mongolian",
    ["monk"] = "Monk",
    ["mordania"] = "Mordanian",
    ["morocco"] = "Moroccan",
    ["moroccans"] = "Moroccan",
    ["morovia"] = "Morovian",
    ["morovians"] = "Morovian",
    ["mtambans"] = "Mtamban",
    ["muvians"] = "Mu",
    ["aboriginal american"] = "Native American",
    ["native"] = "Native American",
    ["neos"] = "Neosian",
    ["norweigan"] = "Norwegian",
    ["norwegians"] = "Norwegian",
    ["narobia"] = "Narobian",
    ["nestralia"] = "Nestralians",
    ["new zealand"] = "New Zealander",
    ["dutch"] = "Dutch",
    ["netherlands"] = "Dutch",
    ["nicaragua"] = "Nicaraguan",
    ["nigeria"] = "Nigerian",
    ["north america"] = "North America",
    ["north korea"] = "North Korean",
    ["oa"] = "Oan",
    ["olympus"] = "God of Olympus",
    ["olympia"] = "God of Olympus",
    ["otero"] = "Oteroans",
    ["pakistan"] = "Pakistani",
    ["peru"] = "Peruvian",
    ["philippines"] = "Filipino",
    ["the philippines"] = "Filipino",
    ["pokolistan"] = "Pokolistani",
    ["poland"] = "Polish",
    ["polynesia"] = "Polynesian",
    ["puerto rica"] = "Puerto Rican",
    ["pyromania"] = "Pyromanian",
    ["pyroman"] = "Pyromanian",
    ["qurac"] = "Quraci",
    ["ramistan"] = "Ramistani",
    ["rimbor"] = "Rimborian",
    ["romania"] = "Romanian",
    ["rome"] = "Roman",
    ["romiro"] = "Romiroan",
    ["russia"] = "Russian",
    ["santa prisca"] = "Santa Priscan",
    ["samoa"] = "Samoan",
    ["saudi arabia"] = "Saudi Arabian",
    ["scandinavia"] = "Scandinavian",
    ["scotland"] = "Scottish",
    ["skartaris"] = "Skartarian",
    ["slorenia"] = "Slorenian",
    ["solar city"] = "Solarian",
    ["somalia"] = "Somalian",
    ["south africa"] = "South African",
    ["south korea"] = "South Korean",
    ["soviet union"] = "Soviet",
    ["spain"] = "Spanish",
    ["sudan"] = "Sudanese",
    ["the sudan"] = "Sudanese",
    ["sweden"] = "Swedish",
    ["switzerland"] = "Swiss",
    ["symkaria"] = "Symkarian",
    ["syria"] = "Syrian",
    ["themyscira"] = "Amazon",
    ["themyscurian"] = "Amazon",
    ["themyscurians"] = "Amazon",
    ["tynanda"] = "Tynandan",
    ["the soviet union"] = "Soviet",
    ["taiwan"] = "Taiwanese",
    ["thailand"] = "Thai",
    ["tibet"] = "Tibetan",
    ["tierra verde"] = "Tierra Verdean",
    ["trans-sabal"] = "Trans-Sabalian",
    ["transbelvia"] = "Transbelvan",
    ["transia"] = "Transian",
    ["transylvania"] = "Transylvanian",
    ["trezygstan"] = "Trezygstani",
    ["tritonis"] = "Tritonian",
    ["troy"] = "Trojan",
    ["tropidor"] = "Tropidoran",
    ["tundi"] = "Tundan",
    ["tunisia"] = "Tunisian",
    ["turkey"] = "Turkish",
    ["uganda"] = "Ugandan",
    ["usa"] = "American",
    ["us"] = "American",
    ["united states"] = "American",
    ["u.s.a."] = "American",
    ["united states of america"] = "American",
    ["united planets"] = "United Planets Citizen",
    ["united kingdom"] = "British",
    ["ukraine"] = "Ukrainian",
    ["union of soviet socialist republics"] = "Soviet",
    ["soviet union"] = "Soviet",
    ["ussr"] = "Soviet",
    ["u.s.s.r."] = "Soviet",
    ["venezuela"] = "Venezuelan",
    ["venegaria"] = "Venegarian",
    ["vietnam"] = "Vietnamese",
    ["scandinavia"] = "Viking",
    ["vlatava"] = "Vlatavan",
    ["wales"] = "Welsh",
    ["wild lands"] = "Wild Lander",
    ["xanthua"] = "Xanthuan",
    ["xebel"] = "Xebelians",
    ["xibalba"] = "Xibalban",
    ["yemen"] = "Yemenis",
    ["yugoslavia"] = "Yugoslavian",
    ["zambesi"] = "Zambesian",
    ["zambia"] = "Zambian",
    ["zandia"] = "Zandian",
    ["zanzibar"] = "Zanzibari",
    ["zenosha"] = "Zenoshan",
    ["zorania"] = "Zoranian",
}
 
citizenship_table = {
	["valid"] = valid,
	["substitutes"] = substitutes
}
 
----------------------------
-- Libraries of functions --
----------------------------
-- stands for High Frequency
local HF = require('Module:ComicsHF')
-- Parses invocation parameters, trims whitespace, and removes blanks.
local getArgs = require('Dev:Arguments').getArgs
-- Gives the name of the current page. It's expensive, so we only do it once.
-- The _G then makes it global, available to all page functions.
_G.vars = { Pagename = mw.title.getCurrentTitle().text }
 
----------------------------------------------------------
-- Public functions (called from a Template or article) --
----------------------------------------------------------
 
-- There is no standalone template, so no public functions.
 
--------------------------------------------------------
-- Internal functions (used in this and other Modules --
--------------------------------------------------------
function valid:in_database( name )
    if type( self[ name ] ) == 'string' then
        return true
    else
        return nil
    end
end
 
function valid:pluralize( name )
    if self:in_database ( name ) then
        return self[name]
    else
        -- Brute force method of making a singular plural
        name = name:gsub( 's$', 'es' )
        name = name:gsub( 'x$', 'es' )
        name = name:gsub( 'z$', 'es' )
        name = name:gsub( 'ch$', 'es' )
        name = name:gsub( 'sh$', 'es' )
        name = name:gsub( 'y$', 'ies' )
        name = name:gsub( 'f$', 'ves' )
        name = name:gsub( 'fe$', 'ves' )
        name = name:gsub( '[^s]$', '%1s' )
        return name
    end
end
 
function valid:link( name )
    return HF.CategoryLink( self:pluralize(name), vars.Pagename, name )
end
 
function substitutes:in_list( name )
    if type( self[ string.lower( name ) ] ) == 'string' then
        return true
    else
        return nil
    end
end
 
function substitutes:sub( name )
    if self:in_list( name ) then
        return self[ string.lower( name ) ]
    else
        return nil
    end
end
 
function substitutes:link( name )
    return HF.CategoryLink( valid[name], vars.Pagename, name )
end
 
function citizenship_table._Citizenship( field, vars )
    local output = ''
    local o = {}
    -- Check for multiple values separated with commas
    local values = HF.explode( ',', field.Value )
 
    for i, v in ipairs( values ) do
        v = HF.trim( v )
        if valid:in_database( v ) then
            -- Check if it's a valid value with a plural form.
            -- If yes - add category links
            table.insert(o, valid:link( v ) )
        elseif substitutes:sub( v ) then
            -- If it's not valid, check for a direct substitution
            -- If there's one in the database, use the corrected one
            table.insert(o, valid:link( substitutes:sub( v ) ) )
        elseif string.match( v, '%[%[.*%]%]' ) then
            -- If it's already a link, leave it alone.
            table.insert(o, v)
        else
            -- 3. If no substitution is found
            -- fallback to a common grammar rules
            -- and add a page to a Category:Needs valid citizenship
            table.insert( o , valid:link( v ) ..
                HF.Category( "Needs valid citizenship", vars.Pagename )
            )
        end
    end
 
    -- If Value2 or ValueRef is provided
    -- concatenate them to the output
    if not HF.isempty( field.Value2 ) then
        output = output .. " " .. field.Value2
    end
    if not HF.isempty( field.ValueRef ) then
        output = output .. " " .. field.ValueRef
    end
 
    return table.concat(o, ' ยท ') .. output
end
 
-------------------------------------------------
-- Output (send it back to whatever called it) --
-------------------------------------------------
return citizenship_table
Community content is available under CC-BY-SA unless otherwise noted.