Modul:list of languages, csv format

A modult a Modul:list of languages, csv format/doc lapon tudod dokumentálni

local languages = mw.loadData("Module:languages/alldata")
local families = mw.loadData("Module:families/data")

-- based on Module:list_of_languages

local export = {}
local filters = {}

function export.show(frame)
	local args = frame.args
	local filter = filters[args[1]]
	local ids = args["ids"]; if not ids or ids == "" then ids = false else ids = true end

	local rows = {}
	-- Get a list of all language codes
	local codes = {}

	for code, _ in pairs(languages) do
		table.insert(codes, code)
	end

	-- Sort the list
	table.sort(codes)

	local sep = ";"
	local minor_sep = ","
	
    local function shallowcopy(array)
    	local new_array = {}
    	for i, v in ipairs(array) do
    		new_array[i] = v
    	end
    	return new_array
    end
    
	-- table.concat can't act on fake table returned by mw.loadData.
	-- shallowcopy converts it to a real table.
    local concat = table.concat
    local function concat_fake(fake_array, sep)
    	return concat(shallowcopy(fake_array), sep)
    end
    
    
	-- Now go over each code, and create table rows for those that are selected
	local column_names = {
		"line", "code", "canonical name", "category", "type", "family code", 
		"family", "sortkey?", "autodetect?",  "exceptional?", "script codes",
		"other names", "standard characters"
	}

	for line, code in ipairs(codes) do
		local data = languages[code]
		
		local row = {}
		
		-- data[1]: canonical name; data[3]: family code
		table.insert(row, line)
		table.insert(row, code)
		table.insert(row, data[1])
		table.insert(row, data[1] .. (data[1]:find("[Ll]anguage$") and "" or " language"))
		table.insert(row, data.type or "")
		table.insert(row, data[3] or "")
		table.insert(row, data[3] and (families[data[3]] and families[data[3]].canonicalName or error(data[3] .. " is not a valid family code (family of " .. code .. ")")))
		table.insert(row, data.sort_key and "sortkey" or "")
		table.insert(row, data.entry_name and "autodetect" or "")
		table.insert(row, code:find("-") and "exceptional" or "")
		
		table.insert(row, data.scripts and concat_fake(data.scripts, minor_sep) or "")
		table.insert(row, data.otherNames and concat_fake(data.otherNames, minor_sep) or "")
		table.insert(row, data.standardChars and "standard characters" or "")

		table.insert(rows, concat(row, sep))
	end

	return "<pre>\n" .. concat(column_names, sep) .. "\n" .. concat(rows, "\n") .. "</pre>"
end

return export