Changes
add a getArgKeys function, so that we can have multiple keys for each argument (helpful for localisation) and so that we only have to create that table once per page
local cfg = require('Module:Namespace detect/config')
local function addKey(t, key, defaultKey)
if key ~= defaultKey then
t[#t + 1] = key
end
end
local function getArgKeys()
-- Returns a table of parameters to query for each default parameter name.
-- This allows wikis to customise parameter names in the cfg table while
-- ensuring that default parameter names will always work. The cfg table
-- values can be added as a string, or as an array of strings.
local argKeys = {
main = {'main'},
talk = {'talk'},
other = {'other'},
subjectns = {'subjectns'},
demospace = {'demospace'},
page = {'page'}
}
for defaultKey, t in pairs(argKeys) do
local cfgValue = cfg[defaultKey]
local cfgValueType = type(cfgValue)
if cfgValueType == 'string' then
addKey(t, cfgValue, defaultKey)
elseif cfgValueType == 'table' then
for i, key in ipairs(cfgValue) do
addKey(t, key, defaultKey)
end
end
cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more.
end
return argKeys
end
local function getParamMappings()
end
return { argKeys = getArgKeys(), cfg = cfg, mappings = getParamMappings()}