Module:auto cat: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 47: Line 47:


-- provides initial capitalisation
-- provides initial capitalisation
local function capitalise(word)
local function capitalize(word)
if mw.ustring.len(word) > 1 then
if mw.ustring.len(word) > 1 then
return mw.ustring.upper(mw.ustring.sub(word, 1, 1)) .. mw.ustring.sub(word, 2)
return mw.ustring.upper(mw.ustring.sub(word, 1, 1)) .. mw.ustring.sub(word, 2)
Line 94: Line 94:
         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, "%%pos", pos))
             table.insert(p_out_cats, replace(p_cat, "^%%pos", capitalize(pos), "%%pos", pos))
         end
         end
         table.insert(out_patterns, to_pattern(replace(p_lua, "%%pos", pos), p_out_cats))
         table.insert(out_patterns, to_pattern(replace(p_lua, "^%%pos", capitalize(pos), "%%pos", pos), p_out_cats))
     end
     end
end
end