Module:Sandbox

local LANGUAGE_CODES = { cs = "Czech", da = "Danish", de = "German", en = "English", es = "Spanish", fi = "Finnish", fr = "French", he = "Hebrew", hu = "Hungarian", it = "Italian", ja = "Japanese", ko = "Korean", nl = "Dutch", no = "Norwegian", pl = "Polish", pt = "Portuguese", ro = "Romanian", ru = "Russian", sv = "Swedish", zh = "Chinese", ["zh-Hans"] = "Simplified Chinese", ["zh-Hant"] = "Traditional Chinese", }

local p = {}

local function split( value ) local pos = string.find(value, ":") return string.gsub(string.sub(value, 0, pos - 1), '^%s*(.-)%s*$', '%1'), string.gsub(string.sub(value, pos + 1, -1), '^%s*(.-)%s*$', '%1') end

local function getOrCreateMember ( t, f, m ) for _, value in ipairs(t) do 		if f(value) then return value end end table.insert(t, m)	return m end

local function processLangs( arg ) local out = {} local lang = {} local word = {} for _, parameter in ipairs(arg) do   	local name, value = split(parameter) if name == "l" then decodedValue = LANGUAGE_CODES[value] lang = getOrCreateMember(out, function(f) return f.l == decodedValue end, {["l"] = decodedValue}) elseif name == "w" then word = getOrCreateMember(lang, function(f) return f.w == value end, {["w"] = value}) else word[name] = value end end return out end

local function processWord(word) out = " " .. word.w	if word.c then out = out .. " (" .. word.c .. ") " end if word.r then out = out .. " ''" .. word.r .. "''"	end out = out .. " "

out = out .. " "	if word.m then out = out .. word.m 	end out = out .. "  "	return out

end

local function processLang(lang) out = " " .. lang.l .. " "	for _, value in ipairs(lang) do out = out .. processWord(value) end out = out .. " "	return out end

function p.main( frame ) local langs = processLangs(frame.args) out = [[ "   return out end

return p