Difference between revisions of "Module:CapitalizationCheck"
From Nookipedia, the Animal Crossing wiki
PanchamBro (talk | contribs) (Undo revision 975416 by PanchamBro (talk)) Tag: Undo |
PanchamBro (talk | contribs) m |
||
Line 43: | Line 43: | ||
if not isEmpty(display) then | if not isEmpty(display) then | ||
if checkCaps(compare, game) == true then | if checkCaps(compare, game) == true then | ||
− | print = | + | print = display |
else | else | ||
− | print = | + | print = frame:preprocess('\'\'\'{{Colorshow|FF0000|{{alt|' .. display .. '|This item is improperly cased per Nookipedia\'s Manual of Style.|?}}}}\'\'\'') |
end | end | ||
else | else | ||
if checkCaps(compare, game) == false then | if checkCaps(compare, game) == false then | ||
− | print = | + | print = "[[Category:Pages with item names improperly capitalized]]" |
end | end | ||
end | end |
Revision as of 18:33, November 26, 2022
Documentation for this module may be created at Module:CapitalizationCheck/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
data = mw.loadData("Module:CapitalizationCheck/Data")
function checkFirstGen(s)
if s == "DnM" then
return true
elseif s == "Doubutsu no Mori" then
return true
elseif s == "DnM+" then
return true
elseif s == "Doubutsu no Mori+" then
return true
elseif s == "PG" then
return true
elseif s == "Animal Crossing" then
return true
elseif s == "DnMe+" then
return true
elseif s == "Doubutsu no Mori e+" then
return true
elseif s == "iQue" then
return true
elseif s == "Dòngwù Sēnlín" then
return true
elseif s == "Dongwu Senlin" then
return true
else
return false
end
end
function p.main(frame)
local function isEmpty(s)
return s == nil or s == ''
end
local print = ''
local args = getArgs(frame)
local compare = args[1] or ''
local game = args[2] or ''
local display = args[3] or ''
if not isEmpty(display) then
if checkCaps(compare, game) == true then
print = display
else
print = frame:preprocess('\'\'\'{{Colorshow|FF0000|{{alt|' .. display .. '|This item is improperly cased per Nookipedia\'s Manual of Style.|?}}}}\'\'\'')
end
else
if checkCaps(compare, game) == false then
print = "[[Category:Pages with item names improperly capitalized]]"
end
end
return print
end
-- https://stackoverflow.com/questions/2421695/first-character-uppercase-lua
function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
function checkCaps(compare, game)
local sentenceCase = ""
if checkFirstGen(game) then
if compare == firstToUpper(data.firstGen[compare:lower()]) then
return true
elseif compare == data.firstGen[compare:lower()] then
return true
else
return false
end
elseif game == "WW" or game == "Wild World" then
if compare == firstToUpper(data.wildWorld[compare:lower()]) then
return true
elseif compare == data.wildWorld[compare:lower()] then
return true
else
return false
end
elseif game == "NH" or game == "New Horizons" then
if compare == firstToUpper(data.newHorizons[compare:lower()]) then
return true
elseif compare == data.newHorizons[compare:lower()] then
return true
else
return false
end
end
end
return p