Difference between revisions of "Module:CapitalizationCheck"

From Nookipedia, the Animal Crossing wiki
m
m
Line 39: Line 39:
  
 
function p.checkCaps(compare, game)
 
function p.checkCaps(compare, game)
print = ''
+
local print = ''
 +
local sentenceCase = ""
 
if checkFirstGen(game) then
 
if checkFirstGen(game) then
 
if compare ~= data.firstGen[compare:lower()] then
 
if compare ~= data.firstGen[compare:lower()] then
Line 53: Line 54:
 
end
 
end
 
elseif game == "NH" or game == "New Horizons" then
 
elseif game == "NH" or game == "New Horizons" then
if compare ~= data.newHorizons[compare:lower()] or mw.getContentLanguage():ucfirst(compare) ~= mw.getContentLanguage():ucfirst(data.newHorizons[compare:lower()]) then
+
sentenceCase = mw.getContentLanguage():ucfirst(data.newHorizons[compare:lower()])
print = print .. "[[Category:Pages with item names improperly capitalized]]"
+
if compare ~= data.newHorizons[compare:lower()] then
 +
print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
 +
elseif mw.getContentLanguage():ucfirst(compare) ~= sentenceCase then
 +
print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
 
end
 
end
 
end
 
end

Revision as of 12:13, November 19, 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 args         = getArgs(frame)
    local compare      = args[1] or ''
    local game         = args[2] or ''
    return p.checkCaps(compare, game)
end

function p.checkCaps(compare, game)
	local print = ''
	local sentenceCase = ""
	if checkFirstGen(game) then
		if compare ~= data.firstGen[compare:lower()] then
			print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
		elseif mw.getContentLanguage():ucfirst(compare) ~= mw.getContentLanguage():ucfirst(data.firstGen[compare:lower()]) then
			print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
		end
	elseif game == "WW" or game == "Wild World" then
		if compare ~= data.wildWorld[compare:lower()] then
			print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
		elseif mw.getContentLanguage():ucfirst(compare) ~= mw.getContentLanguage():ucfirst(data.wildWorld[compare:lower()]) then
			print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
		end
	elseif game == "NH" or game == "New Horizons" then
		sentenceCase = mw.getContentLanguage():ucfirst(data.newHorizons[compare:lower()])
		if compare ~= data.newHorizons[compare:lower()] then
			print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
		elseif mw.getContentLanguage():ucfirst(compare) ~= sentenceCase then
			print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
		end
	end
	return print
end

return p