Module:gender and number: Difference between revisions

Fixed pluralisation of PoS w/ epenthetic <e>
mNo edit summary
(Fixed pluralisation of PoS w/ epenthetic <e>)
Line 52: Line 52:
local groups = {}
local groups = {}
local cats = {}
local cats = {}
local function pluralize(word)
local ending = mw.ustring.sub(word, -1)
if ending == "h" and mw.ustring.sub(word, -2, -1) == "s" then ending = "sh" end
if ending == "s" or ending == "z" or ending == "x" or ending == "sh" then
return word .. "es"
end
return word .. "s"
end
for _, g_code in ipairs(genders) do
for _, g_code in ipairs(genders) do
local split_codes = combinations[g_code] or mw.text.split(g_code, "-")
local split_codes = combinations[g_code] or mw.text.split(g_code, "-")
Line 63: Line 73:
if pos ~= nil then
if pos ~= nil then
if groups[gender.group] == nil then
if groups[gender.group] == nil then
table.insert(cats, "[[Category:" .. language.name .. " " .. string.gsub(gender.category, "%%", pos .. "s") .. "]]")
table.insert(cats, "[[Category:" .. language.name .. " " .. string.gsub(gender.category, "%%", pluralize(pos)) .. "]]")
groups[gender.group] = 1
groups[gender.group] = 1
else
else