Jump to content

မေႃႇၵျူး: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("Module:languages/byTranslitModule")("sa-translit") --> table containing objects for Sanskrit (sa), Punjabi (pa), Old Marathi (omr), Old Hindi (inc-ohi)

return function(translitModule)
	local langs = {}
	
	for code, data in pairs(require("Module:languages/data/all")) do
		if data.translit == translitModule then
			langs[code] = data
		elseif type(data.translit) == "table" then
			for script, translit_data in pairs(data.translit) do
				if translit_data == translitModule then
					langs[code] = data
				end
			end
		end
	end
	
	local result = {}
	local i = 0
	for code, data in pairs(langs) do
		i = i + 1
		result[i] = require("Module:languages").makeObject(code, data)
	end
	
	return result
end