Difference between revisions 21306572 and 21306573 on frwiktionary

local export = {}

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	if mw.title.getCurrentTitle().nsText == "Template" then
		return "(This template should be used on pages in the Category: namespace.)"
	elseif mw.title.getCurrentTitle().nsText ~= "Category" then
(contracted; show full)	end
	
	return ret
end

-- Check the name of the curren page, and return an error if it's not right.
function check_name(info)

	local errortext = nil
	local category = nil
	
	if not export.get_item(info, "label_exists") then
		errortext = "The label given to the " .. mw.getCurrentFrame():expandTemplate{title = "temp", args = {info.template}} .. " template is not valid."
		category = "[[Category:Categories needing attention]]"
	else
		local expected_name = export.get_item(info, (info.code and "basic" or "umbrella"))
	

	
		
		if expected_name ~= mw.title.getCurrentTitle().text then
		return "[[Category:Categories needing attention]]"	errortext = "Based on the parameters given to the " .. mw.getCurrentFrame():expandTemplate{title = "temp", args = {info.template}} .. " template, this category should be called '''[[:Category:" .. expected_name .. "]]'''."
			category = "[[Category:Categories needing attention]]"
		end
	end
	
	if errortext then
		return (category or "") .. mw.getCurrentFrame():expandTemplate{title = "maintenance box", args = {
			"red",
			image = "[[File:Ambox warning pn.svg|50px]]",
			title = "The automatically-generated contents of this category has errors.",
			text = "Based on the parameters given to the " .. mw.getCurrentFrame():expandTemplate{title = "temp", args = {info.template}} .. " template, this category should be called '''[[:Category:" .. expected_name .. "]]'''."errortext,
			}}
	else
		return nil
	end
end

-- Show the parent categories that the current category should be placed in.
(contracted; show full)			return mw.getCurrentFrame():expandTemplate{title = TOC_template.text, args = {}}
		end
	end
	
	return nil
end

return export