Jump to content

WMDE Technical Wishes/Gendered Categories/Migration module

From Meta, a Wikimedia project coordination wiki

-- Safely use category alias
--
-- Example: {{#invoke:catalias|main|Ärtztin}}

local p = {}

-- Setting this to false will cause all pages using the module to go in to alias fallback mode, in which we look up the target category directly.

local aliasingEnabled = false

function p.main (frame)
  if not aliasingEnabled then
    local aliasTitle = mw.title.makeTitle("Category", frame.args[1])
    if aliasTitle.isRedirect then
      return "[[" .. aliasTitle.redirectTarget.prefixedText .. "]]"
    end
  end

  return "[[Category:" .. frame.args[1] .. "]]"
end

return p