Module:auto cat: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 34: Line 34:
end
end
error("Empty input for capitalisation")
error("Empty input for capitalisation")
end
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
end


Line 47: Line 56:
                    local p_out_cats = {}
                    local p_out_cats = {}
                    for _, p_cat in ipairs(p_categories) do
                    for _, p_cat in ipairs(p_categories) do
                    table.insert(p_out_cats, replace(p_cat, {["%%l"] = l_data.name, ["%%u"] = l2_data.name, ["^%%p"] = capitalize(pos), ["%%p"] = pos}))
                    table.insert(p_out_cats, capitalize(replace(p_cat, {["%%l"] = l_data.name, ["%%u"] = l2_data.name, ["%%ps"] = pluralize(pos), ["%%p"] = pos})))
                    end
                    end
                    table.insert(out_patterns, to_pattern(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%u"] = sanitize(l2_data.name), ["^%%p"] = capitalize(pos), ["%%p"] = pos}), p_out_cats))
                    table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%u"] = sanitize(l2_data.name), ["%%ps"] = pluralize(pos), ["%%p"] = pos})), p_out_cats))
                end
                end
            end
            end
Line 55: Line 64:
            local p_out_cats = {}
            local p_out_cats = {}
            for _, p_cat in ipairs(p_categories) do
            for _, p_cat in ipairs(p_categories) do
            table.insert(p_out_cats, replace(p_cat, {["%%l"] = l_data.name, ["^%%p"] = capitalize(pos), ["%%p"] = pos}))
            table.insert(p_out_cats, capitalize(replace(p_cat, {["%%l"] = l_data.name, ["%%ps"] = pluralize(pos), ["%%p"] = pos})))
            end
            end
            table.insert(out_patterns, to_pattern(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["^%%p"] = capitalize(pos), ["%%p"] = pos}), p_out_cats))
            table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%l"] = sanitize(l_data.name), ["%%ps"] = pluralize(pos), ["%%p"] = pos})), p_out_cats))
        end
        end
     end
     end
Line 96: Line 105:
     local p_out_cats = {}
     local p_out_cats = {}
         for _, p_cat in ipairs(p_categories) do
         for _, p_cat in ipairs(p_categories) do
             table.insert(p_out_cats, replace(p_cat, {["^%%p"] = capitalize(pos), ["%%p"] = pos}))
             table.insert(p_out_cats, capitalize(replace(p_cat, {["%%ps"] = pluralize(pos), ["%%p"] = pos})))
         end
         end
         table.insert(out_patterns, to_pattern(replace(p_lua, {["^%%p"] = capitalize(pos), ["%%p"] = pos}), p_out_cats))
         table.insert(out_patterns, to_pattern(capitalize(replace(p_lua, {["%%ps"] = pluralize(pos), ["%%p"] = pos})), p_out_cats))
end
end
end
end

Navigation menu