8,290
edits
(special pluralization case for "vortex") |
m (re-order logic to ensure "with" and "of" phrases are pluralized regardless of how their final word ends) |
||
(3 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' | ||
} | } | ||
if irregularplurals[str] ~= nil then | if irregularplurals[str] ~= nil then | ||
return irregularplurals[str] | return irregularplurals[str] | ||
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 (string.find(str, ' with ')) then | |||
i = string.find(str, ' with ') | |||
return p.pluralize(string.sub(str, 1, i-1)) .. string.sub(str, i) | |||
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') | ||
Line 14: | Line 21: | ||
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.sub(str, -3) == 'ife') and apostrophe == '' then | |||
return (string.sub(str, 1, -4) .. 'ives') | |||
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 | if (str:sub(-6) == 'vortex') then --special case, capitalize vortex the same way the game does in in-game text like Quantum Jitters description |