Module:User lang

-- Syntax: --

local p = {} local getArgs = require('Module:Arguments').getArgs

p.data = {} p.data["-0"] = { "This user does not understand ", "#fbb", "#ffeeee" } p.data["-1"] = { "This user can contribute with a basic level of", "#e0c0e0", "#f3e0f3" } p.data["-2"] = { "This user can contribute with an intermediate level of", "#bcb9ef", "#e9e5f9" } p.data["-3"] = { "This user can contribute with an advanced level of", "#99b3ff", "#e0e8ff" } p.data["-4"] = { "This user can contribute with a near-native level of", "#77e0e8", "#d0f8ff" } p.data["-5"] = { "This user can contribute with a professional level of", "#ffcf4d", "#ffefa6" } p.data["-N"] = { "This user is a native speaker of", "#6ef7a7", "#c5fcdc" } p.data["-*"] = { "This user understands", "#6ef7a7", "#c5fcdc" }

function p.extractLevel(code) local key = "-*" local idx = code:find("-", -2) if idx then key = code:sub(idx) end if not p.data[key] then return "-*" else return key end end

function p.main(frame) local tArgs = p._main(getArgs(frame, {wrappers = 'Template:User_lang'})) return frame:expandTemplate{title = 'User box', args = tArgs} end

function p._main(args) local level = p.extractLevel(args[1]) local tArgs = {} -- language code tArgs["icon"] = " " -- message if args["text"] then tArgs["text"] = args["text"] else tArgs["text"] = p.data[level][1] .. " " .. args[2] .. "."	end -- colors tArgs["border"] = "1px solid " .. p.data[level][2] tArgs["bg_color_1"] = p.data[level][2] tArgs["bg_color_2"] = p.data[level][3] -- margin botton tArgs["options"] = "mtop,mbottom" return tArgs end

return p