Module:Namespace detect/data: Difference between revisions

m
(avoid using local variables to save table lookups per Jackmcbarn's suggestion, and because this will be cached with mw.loadData so performance of this function is not such a worry)
m (1 revision imported from wikipedia:Module:Namespace_detect/data)
 
(8 intermediate revisions by 3 users not shown)
Line 18:
-- values can be added as a string, or as an array of strings.
 
local argKeysdefaultKeys = {
main = {'main'},
talk = {'talk'},
other = {'other'},
subjectns = {'subjectns'},
demospace = {'demospace'},
'demopage'
page = {'page'}
}
 
local argKeys = {}
for i, defaultKey in ipairs(defaultKeys) do
argKeys[defaultKey] = {defaultKey}
end
 
for defaultKey, t in pairs(argKeys) do
Line 59 ⟶ 64:
for nsid, ns in pairs(mw.site.subjectNamespaces) do
if nsid ~= 0 then -- Exclude main namespace.
local nsname = mw.ustring.lower(ns.name)
local canonicalName = mw.ustring.lower(ns.canonicalName)
mappings[nsname] = {mw.ustring.lower(nsname)}
if canonicalName ~= nsname then
table.insert(mappings[nsname], mw.ustring.lower(canonicalName))
end
for _, alias in ipairs(ns.aliases) do