Module:list of families/toplevel

Hello, you have come here looking for the meaning of the word Module:list of families/toplevel. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:list of families/toplevel, but we will also tell you about its etymology, its characteristics and you will know how to say Module:list of families/toplevel in singular and plural. Everything you need to know about the word Module:list of families/toplevel you have here. The definition of the word Module:list of families/toplevel will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:list of families/toplevel, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}
local filters = {}

local function get_parent(families, code)
	if not families then return nil end
	local parent = families
	local last_parent = nil
	while true do
		if parent == nil or parent == "qfa-not" then
			return last_parent
		end
		
		last_parent = parent
		if not families then
			return nil
		end
		
		parent = families
	end
end

function export.show(frame)
	local args = frame.args
	local filter = filters]
	local families = require("Module:families/data")
	local languages = require("Module:languages/data/all")
	local stats = {}

	for code, _ in pairs(families) do
		if not get_parent(families, data) then
			stats = { langs = {}, subfams = {} }
		end
	end 

	for code, data in pairs(languages) do
		local family_code = data
		family_code = get_parent(families, family_code) or family_code
		local fdata = stats
		if fdata then
			table.insert(fdata.langs, code)
		end
	end

	for code, data in pairs(families) do
		local family_code = data
		family_code = get_parent(families, family_code) or family_code
		local fdata = stats
		if fdata then
			table.insert(fdata.subfams, code)
		end
	end

	local codes = {}
 
	for code, _ in pairs(families) do
		table.insert(codes, code)
	end 
	table.sort(codes)
 
	local rows = {}
	for i, code in ipairs(codes) do
		local data = families

		if not get_parent(families, code) then
			local rt = nil
			if data.otherNames then
				local i = 1
				rt = {}
				while data.otherNames do
					table.insert(rt, data.otherNames)
					i = i + 1
				end
			end
	
			if (not filter) or filter(code, data, args) then
				local catname = data .. (data:find("anguages") and "" or " languages")
				catname = catname:sub(1, 1):upper() .. catname:sub(2)
	
				table.insert(rows, string.format(
					' id="%s"\n' ..
					'| <code>%s</code>\n' ..
					'| ]\n' ..
					'| %s\n' ..
					'| %u\n' ..
					'| %u\n',
					code, code,
					catname, data,
					rt and table.concat(rt, ", ") or "&nbsp;",
					#stats.subfams,
					#stats.langs
				))
			end
		end
	end

	return
		"{| class=\"wikitable sortable\"\n" ..
		"! Code\n" ..
		"! Canonical name\n" ..
		"! Other names\n" ..
		"! All subfamilies\n" ..
		"! All languages\n" ..
		"|-" .. table.concat(rows, "\n|-") .. "\n|}"
end

filters = function (code, data, args)
	local firstletter = args
	return data ~= "qfa-not" and code:find("^" .. (firstletter or "") .. "$") ~= nil
end

filters = function (code, data, args)
	return data ~= "qfa-not" and code:find("-") ~= nil
end

filters = function (code, data, args)
	return data == "qfa-not"
end

return export