FANDOM


-- <nowiki>
--------------------------------------------------------------------------------
-- Takes the name of a module, makes it case-insensitive, and splits it into a
-- prefix and root. If no prefix is given, "Module" is used.
--------------------------------------------------------------------------------
local checkType = require("libraryUtil").checkType
local uLower = mw.ustring.lower
local lang = mw.getContentLanguage()
 
return function (name)
    checkType("normalize", 1, name, "string")
 
    -- Split `name` into two parts:
    -- `prefix` - everything up to and including the first colon
    -- `root` - everything after `prefix`
    local prefix, root = name:match("^([^:]+:)(.+)$")
    prefix = uLower(prefix or "")
 
    -- When loading a module, these prefixes will work:
    local localNsName = uLower(mw.site.namespaces[828].name) .. ":"
    local validPrefixes = {
        ["dev:"] = true,     -- added by Wikia
        ["module:"] = true,  -- canonical namespace name
        [localNsName] = true -- namespace name in your language
    }
 
    -- `name` has no prefix
    if not validPrefixes[prefix] then
        prefix = "Module:"
        root = name
    end
 
    return lang:ucfirst(prefix), lang:ucfirst(root)
end
 
-- </nowiki>
-- (Add categories here.)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.