Bu modul uchun Modul:languages/error/doc nomli hujjat sahifasini yaratishingiz mumkin

return function(lang_code, param, code_desc, template_tag, not_real_lang)
	local ordinals = {
		"first", "second", "third", "fourth", "fifth", "sixth",
		"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth",
		"thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth",
		"eighteenth", "nineteenth", "twentieth"
	}
	
	code_desc = code_desc or "language code"

	local param_type = type(param)
	if not template_tag then
		template_tag = ""
	else
		if type(template_tag) ~= "string" then
			template_tag = template_tag()
		end
		template_tag = " (original template: " .. template_tag .. ")"
	end
	local function err(msg)
		msg = msg .. template_tag
		if param_type == "function" then
			param(msg, 3)
		else
			error(msg .. template_tag .. ".", 3)
		end
	end
	local in_the_param
	if param == true or param_type == "function" then
		-- handled specially below
		in_the_param = ""
	else
		if param_type == "number" then
			if ordinals[param] then
				param = ordinals[param] .. " parameter"
			else
				param = " parameter " .. param
			end
		elseif param_type == "string" then
			param = 'parameter "' .. param .. '"'
		else
			err("The parameter name is "
					.. (param_type == "table" and "a table" or tostring(param))
					.. ", but it should be a number or a string")
		end
		in_the_param = " in the " .. param
	end
	
	if not lang_code or lang_code == "" then
		if param == true or param_type == "function" then
			err("The " .. code_desc .. " is missing")
		else
			err("The " .. param .. " (" .. code_desc .. ") is missing")
		end
	elseif type(lang_code) ~= "string" then
		err("The " .. code_desc .. in_the_param .. " is supposed to be a string but is a " .. type(lang_code))
	-- Can use string.find because language codes only contain ASCII.
	elseif not_real_lang or lang_code:find("^%l%l%l?$")
			or lang_code:find("^%l%l%l%-%l%l%l$")
			or lang_code:find("^%l%l%l%-%l%l%l%-%l%l%l$") then
		err("The " .. code_desc .. " \"" .. lang_code .. "\"" .. in_the_param .. " is not valid (see [[Wiktionary:List of languages]])")
	else
		err("Please specify a " .. code_desc .. in_the_param .. "; the value \"" .. lang_code .. "\" is not valid (see [[Wiktionary:List of languages]])")
	end
end