Difference between revisions of "Module:SentenceCase"
From Nookipedia, the Animal Crossing wiki
PanchamBro (talk | contribs) (adding amiibo shelf) |
HylianAngel (talk | contribs) (Áo dài was showing up as "áo dài" in the infobox.) |
||
Line 20: | Line 20: | ||
function p.firstToUpper(name) | function p.firstToUpper(name) | ||
local keepLowercase = {"iQue", "iQue shirt", "iQueGBA", "amiibo shelf"} | local keepLowercase = {"iQue", "iQue shirt", "iQueGBA", "amiibo shelf"} | ||
+ | local aoDai = {"áo dài"} | ||
if search(name, keepLowercase) == true then | if search(name, keepLowercase) == true then | ||
return name | return name | ||
+ | elseif search(name, aoDai) == true then | ||
+ | return "Áo dài" | ||
else | else | ||
return (name:gsub("^%l", string.upper)) | return (name:gsub("^%l", string.upper)) |
Latest revision as of 00:05, March 7, 2023
Documentation for this module may be created at Module:SentenceCase/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
function search(category, substrings)
for k,v in pairs(substrings) do
if string.find(category, v) then
return true
end
end
return false
end
function p.main(frame)
local args = getArgs(frame)
local name = args['1'] or ''
return p.firstToUpper(name)
end
-- https://stackoverflow.com/questions/2421695/first-character-uppercase-lua
function p.firstToUpper(name)
local keepLowercase = {"iQue", "iQue shirt", "iQueGBA", "amiibo shelf"}
local aoDai = {"áo dài"}
if search(name, keepLowercase) == true then
return name
elseif search(name, aoDai) == true then
return "Áo dài"
else
return (name:gsub("^%l", string.upper))
end
end
return p