Module:labels/data/functions

Hello, you have come here looking for the meaning of the word Module:labels/data/functions. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:labels/data/functions, but we will also tell you about its etymology, its characteristics and you will know how to say Module:labels/data/functions in singular and plural. Everything you need to know about the word Module:labels/data/functions you have here. The definition of the word Module:labels/data/functions will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:labels/data/functions, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

function export.typecheck(labels)
	local errors = require "Module:array"()
	for label, data in pairs(labels) do
		local languages, language = data, data
		if languages then
			if type(languages) ~= "table" then
				errors:insert("languages value for " .. label .. " is not a table")
			else
				for i, language in ipairs(languages) do
					if type(language) ~= "string" then
						errors:insert(
							"value #" .. i .. " in languages value for "
								.. label .. " is not a string")
					else
						data = true
					end
				end
			end
		elseif language then
			if type(language) ~= "string" then
				errors:insert(
					"language value for " .. label .. " is not a string")
			else
				data = {}
				data = true
			end
		end
	end
	if #errors > 0 then
		error(errors:concat ", ")
	end
end

function export.handle_languages(labels)
	if type(labels) ~= "table" then
		error('The function "handle_languages" requires a table as argument.')
	end
	
	if mw.title.getCurrentTitle().fullText:find "Module:labels" then
		return export.typecheck(labels)
	end
	
	for label, data in pairs(labels) do
		local languages, language = data, data
		if languages then
			for _, language in ipairs(languages) do
				languages = true
			end
		elseif language and language ~= "" then
			data = {}
			data = true
		end
	end
end

return export