Module:languages/byTranslitModule

Ut Wikiwurdboek
Springe nei navigaasje Springe nei sykjen
return function(translitModule)
	local langs = {
		n = 0,
		add = function(self, value)
			self.n = self.n + 1
			self[self.n] = value
		end
	}
	
	local m_redirect = mw.loadData("Module:translit-redirect/data")
	local makeObject = require("Module:languages").makeObject
	
	local function iterate(list)
		for code, data in pairs(list) do
			if data.translit_module == translitModule then
				langs:add(makeObject(code, data))
			elseif data.translit_module == "translit-redirect" and m_redirect[code] then
				for scriptCode, translitRedirectData in pairs(m_redirect[code]) do
					if type(translitRedirectData) == "table" and translitRedirectData.module == translitModule then
						langs:add(makeObject(code, data))
					end
				end
			end
		end
	end
	
	iterate(mw.loadData("Module:languages/data2"))
	
	for letter in string.gmatch("abcdefghijklmnopqrstuvwxyz", ".") do
		iterate(mw.loadData("Module:languages/data3/" .. letter))
	end
	
	iterate(mw.loadData("Module:languages/datax"))
	
	return langs
end