Module:Labels/data/functions

From The Languages of David J. Peterson
Jump to navigation Jump to search

Documentation for this module may be created at Module:Labels/data/functions/documentation

export = {}

function export.handle_languages(labels)
	if type(labels) ~= "table" then
		error('The function "handle_languages" requires a table as argument.')
	end
	
	for label, data in pairs(labels) do
		if data["languages"] then
			for key, language in ipairs(data["languages"] or {}) do
				labels[label]["languages"][language] = true
			end
		elseif data["language"] and data["language"] ~= "" then
			labels[label]["languages"] = {}
			labels[label]["languages"][data["language"]] = true
		end
	end
end

return export