Difference between revisions 21306684 and 21306685 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 
not parent.label then
			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 .. "]]")
		elseif type(parent.label or parent.name) == "string" then
			if (parent.label or parent.name):find("^Category:") then
	type(parent.name) == "string" 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_nametable.insert(categories, "[[Category:" .. parent.name:getCategoryName() .. "|" .. parent.sort .. "]]")
		end
	end
	
	-- Also put the category in its corresponding "umbrella" or "by language" category.
	local umbrella = current:getUmbrella()
	
	if umbrella then
(contracted; show full)			return mw.getCurrentFrame():expandTemplate{title = TOC_template.text, args = {}}
		end
	end
	
	return nil
end

return export