Module:languages/getDescendants

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

This module was intended to generate a list of all immediate descendants of a given language (say, Proto-Germanic), but it has failed by passing the limits of Lua processing time or memory.


-- Returns language objects for descendants of a language.

local validateLangCode = mw.loadData("Module:languages/code to canonical name")

local function getProto(family, code)
	return family.protoLanguage or
			validateLangCode and code .. "-pro"
end

return function(langCode)
	local langs = {}
	local families = {}
	
	local function iterate(dataModule)
		for code, data in pairs(dataModule) do
			if data.ancestors then
				for i, ancestor in pairs(data.ancestors) do
					if ancestor == langCode then
						table.insert(langs, require("Module:languages").getByCode(code))
					end
				end
			elseif data then
				local familyCode = data
				local familyCodeChain = {}
				
				family = mw.loadData("Module:families/data")
				local protoLanguage = families or
						getProto(family, familyCode)
				if not protoLanguage then
					table.insert(familyCodeChain, familyCode)
				end
				
				while not protoLanguage do
					familyCode = family
					table.insert(familyCodeChain, familyCode)
					if family then
						protoLanguage = getProto(family, familyCode)
					else
						break
					end
				end
				
				if familyCodeChain then
					for i, familyCode in pairs(familyCodeChain) do
						families = protoLanguage or "none"
					end
				end
				
				if protoLanguage == langCode then
					table.insert(langs, require("Module:languages").getByCode(code))
				end
			end
		end
	end
	
	iterate(mw.loadData("Module:languages/data/2"))
	
	--[[
	for letter in mw.ustring.gmatch("abcdefghijklmnopqrstuvwxyz", "(.)") do
		iterate(mw.loadData("Module:languages/data/3/" .. letter))
	end
	
	iterate(mw.loadData("Module:languages/data/exceptional"))
	]]
	
	return langs
end