Script error: The function "main" does not exist.

local export = {}

-- Category object

local Category = {}
Category.__index = Category


function Category.new_main(frame)
	local params = {
		[1] = {},
		[2] = {required = true},
	}
	
	args = require("Module:parameters").process(frame:getParent().args, params)
	
	return Category.new({code = args[1], label = args[2]})
end


function Category.new(info)
	for key, val in pairs(info) do
		if not (key == "code" or key == "label") then
			error("The parameter \"" .. key .. "\" was not recognized.")
		end
	end
	
	local self = setmetatable({}, Category)
	self._info = info
	
	if not self._info.label then
		error("No label was specified.")
	end
	
	self._lang = self._info.code and (require("Module:languages").getByCode(self._info.code) or error("The language code \"" .. self._info.code .. "\" is not valid.")) or nil
	self._source = 
		require("Module:families").getByCode(self._info.label) or
		require("Module:etymology languages").getByCode(self._info.label) or
		require("Module:languages").getByCode(self._info.label) or 
		error("\"" .. self._info.label .. "\" is not a valid language, family or etymology-only language code.")
	
	return self
end

export.new = Category.new
export.new_main = Category.new_main


function Category:getInfo()
	return self._info
end


function Category:getBreadcrumbName()
	return (not self._lang and "terms calqued from " or "") .. self._source:getCanonicalName()
end


function Category:getDataModule()
	return "Module:category tree/calque cat"
end


function Category:canBeEmpty()
	return false
end


function Category:isHidden()
	return false
end


function Category:getCategoryName()
	local ret = nil
	
	if self._source:getType() == "family" then
		ret = self._source:getCategoryName()
	else
		ret = self._source:getCanonicalName()
	end
	
	if self._lang then
		return mw.getContentLanguage():ucfirst(self._lang:getCanonicalName() .. " terms calqued from " .. ret)
	else
		return "Terms calqued from " .. ret
	end
end


function Category:getDescription()
	if not self._lang then
		return "Categories with terms calqued from " .. self._source:getCanonicalName() .. " in various specific languages."
	else
		if self._source:getType() == "family" then
			return "Terms in " .. self._lang:getCanonicalName() .. " that were calqued from unknown [[:Category:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()) .. "|" .. self._source:getCategoryName() .. "]].\n\n"
		elseif self._source:getType() == "etymology language" then
			return "Terms in " .. self._lang:getCanonicalName() .. " that were calqued from " .. self._source:getCanonicalName() .. "."
		else
			return "Terms in " .. self._lang:getCanonicalName() .. " that were calqued from the [[:Category:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()) .. "|" .. self._source:getCategoryName() .. "]]."
		end
	end
end


function Category:getParents()
	if self._lang then
		return {
			{name = require("Module:category tree/poscatboiler").new({code = self._info.code, label = "calques"}), sort = self._source:getCanonicalName()},
			{name = require("Module:category tree/borrowed cat").new({code = self._info.code, label = self._source:getCode()}), sort = " "},
			}
	else
		return {{name = require("Module:category tree/borrowed cat").new({label = self._source:getCode()}), sort = " "}}
	end
end

function Category:getChildren()
	return nil
end


function Category:getUmbrella()
	if not self._lang then
		return nil
	end
	
	local uinfo = mw.clone(self._info)
	uinfo.code = nil
	return Category.new(uinfo)
end


return export