require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local importance = mw.loadData('Module:Importance/data')
local p = {}
local function ret(args, i)
if args[2] == 'simp' then
return importance[i].name
end
if args[2] == 'trad' then
return importance[i].name2
end
return importance[i].code
end
function p.main(frame)
local args = getArgs(frame, {frameOnly = true})
return p._main(args)
end
function p._main(args)
-- Main module code goes here.
local str = string.lower(args[1] or 'unknown')
for i, v in pairs(importance) do
if str == v.code then
return ret(args, i)
end
if str == v.name or str == v.name2 then
return ret(args, i)
end
for j, w in ipairs(v.alias) do
if str == w then
return ret(args, i)
end
end
end
return ret(args, 0)
end
return p