532
edits
(capitalize) |
(improved pluralization for things with "of" in the name (drops of nectar, clumps of grave moss, knight commanders of the holy temple, etc)) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
apostrophe = apostrophe or '' | apostrophe = apostrophe or '' | ||
local irregularplurals = { | local irregularplurals = { | ||
Man = 'Men', | |||
man = 'men' | man = 'men' | ||
} | } | ||
Line 10: | Line 11: | ||
elseif (str:sub(-1) == 's') then | elseif (str:sub(-1) == 's') then | ||
return (str .. apostrophe) --return unmodified (ends with 's', like 'boots', so we shouldn't append another 's') | return (str .. apostrophe) --return unmodified (ends with 's', like 'boots', so we shouldn't append another 's') | ||
elseif (string.sub(str, -2) == 'ey') and apostrophe == '' then | |||
return (str .. 's') --for example, "lamprey" | |||
elseif (string.sub(str, -1) == 'y') and apostrophe == '' then | elseif (string.sub(str, -1) == 'y') and apostrophe == '' then | ||
return (string.sub(str, 1, -2) .. 'ies') | return (string.sub(str, 1, -2) .. 'ies') | ||
elseif (string.find(str, ' of ')) then | |||
i = string.find(str, ' of ') | |||
return p.pluralize(string.sub(str, 1, i-1)) .. string.sub(str, i) | |||
elseif (str:sub(-1) == 'z' or str:sub(-2) == 'ch' or str:sub(-2) == 'sh' or str:sub(-1) == 'x') and apostrophe == '' then | elseif (str:sub(-1) == 'z' or str:sub(-2) == 'ch' or str:sub(-2) == 'sh' or str:sub(-1) == 'x') and apostrophe == '' then | ||
if (str:sub(-6) == 'vortex') then --special case, capitalize vortex the same way the game does in in-game text like Quantum Jitters description | |||
return (string.sub(str, 1, -3) .. 'ices') | |||
end | |||
return (str .. 'es') | return (str .. 'es') | ||
else | else | ||
Line 31: | Line 40: | ||
["'re"] = "'s", | ["'re"] = "'s", | ||
["don't"] = "doesn't", | ["don't"] = "doesn't", | ||
["'ve"] = "'s" | ["'ve"] = "'s", | ||
["do"] = "does" | |||
} | } | ||
local result = irregularsingulars[string] | local result = irregularsingulars[string] | ||
Line 42: | Line 52: | ||
function p.capitalize(str) | function p.capitalize(str) | ||
return str:gsub("^%l", string.upper) | return str:gsub("^%l", string.upper) | ||
end | end | ||
return p | return p |