Editing Module:Namespace detect/data
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 6: | Line 6: | ||
local cfg = require('Module:Namespace detect/config') | local cfg = require('Module:Namespace detect/config') | ||
local function getParamMappings() | local function getParamMappings() | ||
Line 57: | Line 19: | ||
-- } | -- } | ||
--]] | --]] | ||
local ustringLower = mw.ustring.lower | |||
local tinsert = table.insert | |||
local subjectNamespaces = mw.site.subjectNamespaces | |||
local talk = cfg.talk | |||
local mappings = {} | local mappings = {} | ||
mappings[ustringLower(subjectNamespaces[0].name)] = {cfg.main} | |||
mappings[talk] = {talk} | |||
for nsid, ns in pairs(subjectNamespaces) do | |||
mappings[ | |||
for nsid, ns in pairs( | |||
if nsid ~= 0 then -- Exclude main namespace. | if nsid ~= 0 then -- Exclude main namespace. | ||
local nsname = | local nsname = ustringLower(ns.name) | ||
local canonicalName = | local canonicalName = ustringLower(ns.canonicalName) | ||
mappings[nsname] = {nsname} | mappings[nsname] = {nsname} | ||
if canonicalName ~= nsname then | if canonicalName ~= nsname then | ||
tinsert(mappings[nsname], canonicalName) | |||
end | end | ||
for _, alias in ipairs(ns.aliases) do | for _, alias in ipairs(ns.aliases) do | ||
tinsert(mappings[nsname], ustringLower(alias)) | |||
end | end | ||
end | end | ||
Line 78: | Line 42: | ||
end | end | ||
return { | return {cfg = cfg, mappings = getParamMappings()} | ||
} |