[create]
The documentation for this module is missing. Click here to create it.
-- <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.)