10,992
editsMore actions
no edit summary
No edit summary |
No edit summary |
||
Line 50: | Line 50: | ||
} | } | ||
local function | local function makePlural(str) | ||
local sp = specialPlurals[str] | local sp = specialPlurals[str] | ||
if sp then | if sp then | ||
Line 59: | Line 59: | ||
end | end | ||
return str .. "s" | return str .. "s" | ||
end | |||
local function makeSingular(str) | |||
local special | |||
for k, v in pairs(specialPlurals) do | |||
if v == str then | |||
special = k | |||
break | |||
end | |||
end | |||
if special then | |||
return special | |||
end | |||
if str:sub(-3) == "ies" then | |||
return str:sub(1, -4) .. "y" | |||
end | |||
return str:sub(1, -2) | |||
end | end | ||
local function processElement(str) | local function processElement(str) | ||
local modified = str | |||
if makeElementsPlural then | if makeElementsPlural then | ||
modified = makePlural(str) | |||
if makeElementsLinks then | elseif makeElementsSingular then | ||
modified = makeSingular(str) | |||
end | |||
if makeElementsLinks then | |||
return "[[" .. str .. "|" .. modified .. "]]" | |||
else | else | ||
return modified | |||
end | end | ||
end | end | ||
Line 128: | Line 142: | ||
listDelimiters = args['delimiter'] or "," | listDelimiters = args['delimiter'] or "," | ||
makeElementsLinks = args['makeLinks'] | makeElementsLinks = args['makeLinks'] | ||
makeElementsPlural = | makeElementsPlural = args['makePlural'] | ||
makeElementsSingular = args['makeSingular'] | makeElementsSingular = args['makeSingular'] | ||
finalJoiningWord = args['joinWord | finalJoiningWord = args['joinWord'] or "and" | ||
local type = args['type'] or 'sentence' | local type = args['type'] or 'sentence' |