(deasbaireachd⧼tpt-languages-separator⧽deasaich⧼tpt-languages-separator⧽eachdraidh⧼tpt-languages-separator⧽ceanglaichean⧼tpt-languages-separator⧽doc⧼tpt-languages-separator⧽bogsa-gainmhich⧼tpt-languages-separator⧽cùisean deuchainn)

Used to create Mòideal:Language/data/ISO 639-1. By default gets it data from Mòideal:Language/data/iana languages, but can be changed by setting parameter 1 to the desired input. The module only adds table values with a key that has two letters in it.


getArgs = require('Module:Arguments').getArgs
function extract (frame)
	local export = {}
	local args = getArgs(frame)
	local data = args[1] or 'Module:Language/data/iana languages'
	local data = mw.loadData(data)
	for k,v in pairs(data) do
		if k == mw.ustring.match(k,'%a%a') then
			local temp = '["'..k..'"] = {'
			for key,value in pairs(v) do
				temp = temp..'"'..value..'", '
			end
			temp = temp..'},<br />'
			temp = mw.ustring.gsub(temp,', }','}')
			table.insert(export,temp)
		end
	end
	table.sort(export)
	return 'return {<br />'..table.concat(export)..'}'
end
return {extract = extract}