Difference between revisions 21306681 and 21306682 on frwiktionary

local export = {}
local m_languages = require('Module:languages')

-- 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.)"
(contracted; show full)	local parents = current:getParents()
	
	if not parents then
		return
	end
	
	for _, parent in ipairs(parents) do
		if type(
parent.label or parent.name) == "string" then
			if (parent.label or parent.name):find("^Category:") then
				table.insert(categories, "[[" .. (parent.label or parent.name) .. "|" .. parent.sort .. "]]")
			else
				local psort = parent.sort; parent.sort = nil
				local ptemplate = parent.template; parent.template = nil
				
				parent = require("Module:category tree/" .. ptemplate).new(parent)
				table.insert(categories, "[[Category:" .. parent:getCategoryName() .. "|" .. psort .. "]]")
			end
		else
			local parent_name = (parent.label or parent.name):getCategoryName()
			table.insert(categories, "[[Category:" .. parent_name .. "|" .. parent.sort .. "]]")
		end
	end
	
	-- Also put the category in its corresponding "umbrella" or "by language" category.
	local umbrella = current:getUmbrella()
	
(contracted; show full)			return mw.getCurrentFrame():expandTemplate{title = TOC_template.text, args = {}}
		end
	end
	
	return nil
end

return export