Module:Wt/haw/languages/by name

This module generates a table which maps language names to language codes. It is then loaded by Module:Wt/haw/languages using mw.loadData() to perform data lookup by name.


local export = {}

local function iterate(list)
	for code, data in pairs(list) do
		export[data.canonicalName] = code
		
		if data.otherNames then
			for i, otherName in pairs(data.otherNames) do
				if not export[otherName] then
					export[otherName] = code
				end
			end
		end
	end
end

iterate(mw.loadData("Module:Wt/haw/languages/data2"))

for letter in mw.ustring.gmatch("abcdefghijklmnopqrstuvwxyz", "(.)") do
	iterate(mw.loadData("Module:Wt/haw/languages/data3/" .. letter))
end

iterate(mw.loadData("Module:Wt/haw/languages/datax"))

return export