Модул:languages/byTranslitModule

Документација модула[прикажи] [уреди] [историја] [освежи]

Returns a function that generates a list of all the languages that use a given transliteration module. Used by {{translit module documentation}} and {{module cat}}.

Receives the name of a module (minus the namespace Module:) and returns a table (array) of language objects.

require("Модул:languages/byTranslitModule")("sa-translit") --> table containing objects for Sanskrit (sa), Punjabi (pa), Old Marathi (omr), Old Hindi (inc-ohi)

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("Модул:translit-redirect/data")
	local makeObject = require("Модул: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("Модул:languages/data2"))
	
	for letter in string.gmatch("abcdefghijklmnopqrstuvwxyz", ".") do
		iterate(mw.loadData("Модул:languages/data3/" .. letter))
	end
	
	iterate(mw.loadData("Модул:languages/datax"))
	
	return langs
end