模組:Class/convert/sandbox
< Module:Class | convert
这是Module:Class/convert(差异)的沙盒。 |
require('strict')
local getArgs = require('Module:Arguments').getArgs
local class = mw.loadData('Module:Class/data/sandbox')
local p = {}
local function ret(args, i)
if args[2] == 'simp' then
return class[i].name
end
if args[2] == 'trad' then
return class[i].name2
end
return class[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 'unassessed')
for i, v in pairs(class) do
if str == v.code then
return ret(args, i)
end
if str == v.name or str == v.name .. '级' then
return ret(args, i)
end
if str == v.name2 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