Difference between revisions 21306614 and 21306615 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
		end
	end
end

-- Show navigational "breadcrumbs" at the top of the page.
function show_breadcrumbs(template, info)

	if not info.code and export.get_item(template, info, "umbrella-categorization") ~= "parallel" then
		return nil
	end
	
	local steps = {}
	
	-- Start at the current label and move our way up the "chain" from child to parent, until we can't go further.
	local current = info.label
	
	while current do
		local parents = export.get_item(template, {code = info.code, label = current, sc = nil}, "parents"(info.code and "parents" or "umbrella_parents"))
		local parent = parents and parents[1] or nil
		
		if not parent then
			break
		elseif type(parent) == "table" then
			parent = parent.name
		end
(contracted; show full)			return mw.getCurrentFrame():expandTemplate{title = TOC_template.text, args = {}}
		end
	end
	
	return nil
end

return export