Module:Lang

-- local p = {} local param = { } local langCode = require('Module:Lang/code') function trim(s) return s:match "^%s*(.-)%s*$" end function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {		parentFirst = true,		wrappers = {			'Template:Lang'		},	}) return p._main(args) end function eachLang(altLangs,args,tBlock,key,value) local part = mw.html.create('span') local append = {} if langCode[key] then if not(args.mini) then part:wikitext(" " .. langCode[key] .. " " .. ": ") end part:tag("span") :attr("lang",key) :wikitext(value) if tBlock[key .. "_rm"] then -- Romanization table.insert(append,""..args[key .. "_rm"].."") end if tBlock[key .. "_tn"] then -- Translation table.insert(append,"\""..args[key .. "_tn"].."\"") end if #append>0 then part:wikitext(" "..table.concat(append,", ")) end else part:wikitext(key.. ": " .. value) end table.insert(altLangs,tostring(part)) end function p._main(args) local out = mw.html.create('')

local tBlock = {sort=true,mini=true}

--Obtain all _tn keys for k,v in pairs(args) do		if mw.ustring.find(k, "_rm$") or mw.ustring.find(k, "_tn$") then tBlock[k]=true end end --Obtain all numerical keys for k,v in ipairs(args) do		tBlock[k]=true end

--Output default Value out:wikitext(args[1]) local altLangs = {} --Process Sort Paremeter (Split by Delimiter: comma) for sKey in string.gmatch(args.sort or "", "([^,]+)") do		if not(tBlock[sKey]) and args[sKey] then eachLang(altLangs,args,tBlock,sKey,args[sKey]) tBlock[sKey]=true end end

--Process Rest for key,value in pairs(args) do		if not(tBlock[key]) then eachLang(altLangs,args,tBlock,key,value) end end if #altLangs>0 then if not(args.mini) then out:wikitext(' (')		end		out:wikitext(table.concat(altLangs,'; '))		if not(args.mini) then			out:wikitext(')') end end return tostring(out) end

return p