Difference between revisions 21306678 and 21306679 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)	
	if current:isHidden() then
		table.insert(categories, "__HIDDENCAT__")
	end
	
	table.insert(boxes, show_catfix(current))
	table.insert(boxes, show_editlink(current))
	table.insert(boxes, show_pagelist(
infocurrent))
	
	-- Generate the displayed information
	table.insert(display, show_breadcrumbs(current))
	table.insert(display, show_description(current))
	table.insert(display, show_children(current))
	table.insert(display, show_TOC(infocurrent))
	
	show_categories(current, categories)
	
	return table.concat(categories, "") .. table.concat(boxes, "\n") .. "\n" .. table.concat(display, "\n\n")
end

function show_error(text)
(contracted; show full)		end
	end
	
	return table.concat(children_list, "\n")
end

-- Show a table of contents with links to each letter in the language's script.
function show_TOC(
infocurrent)
	local code = current._info.code
	
	if not code or not require("Module:languages").getByCode(code) then
		return nil
	end
	
	local num_pages = 300 --mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "pages")
	
	-- No need for a TOC if all entry names can fit on one page.
	if num_pages > 200 then
		-- This category is very large, see if there is an "extended" version of the TOC.
		if num_pages > 2500 then
			local TOC_template_extended = mw.title.new("Template:" .. code .. "-categoryTOC/full")
			
			if TOC_template_extended.exists then
				return mw.getCurrentFrame():expandTemplate{title = TOC_template_extended.text, args = {}}
			end
		end
		
		local TOC_template = mw.title.new("Template:" .. code .. "-categoryTOC")
		
		if TOC_template.exists then
			return mw.getCurrentFrame():expandTemplate{title = TOC_template.text, args = {}}
		end
	end
	
	return nil
end

return export