<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.digitalcellulose.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACategory_tree%2Ftopic_cat</id>
	<title>Module:Category tree/topic cat - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.digitalcellulose.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACategory_tree%2Ftopic_cat"/>
	<link rel="alternate" type="text/html" href="https://www.digitalcellulose.com/wiki/index.php?title=Module:Category_tree/topic_cat&amp;action=history"/>
	<updated>2026-05-09T13:12:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://www.digitalcellulose.com/wiki/index.php?title=Module:Category_tree/topic_cat&amp;diff=98771&amp;oldid=prev</id>
		<title>Adminsuzy: Created page with &quot;local export = {}  local labels = require(&quot;Module:category tree/topic cat/data&quot;)  -- Category object  local Category = {} Category.__index = Category   function Category.new_m...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.digitalcellulose.com/wiki/index.php?title=Module:Category_tree/topic_cat&amp;diff=98771&amp;oldid=prev"/>
		<updated>2018-09-06T23:50:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local labels = require(&amp;quot;Module:category tree/topic cat/data&amp;quot;)  -- Category object  local Category = {} Category.__index = Category   function Category.new_m...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local export = {}&lt;br /&gt;
&lt;br /&gt;
local labels = require(&amp;quot;Module:category tree/topic cat/data&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Category object&lt;br /&gt;
&lt;br /&gt;
local Category = {}&lt;br /&gt;
Category.__index = Category&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category.new_main(frame)&lt;br /&gt;
	local self = setmetatable({}, Category)&lt;br /&gt;
	&lt;br /&gt;
	local params = {&lt;br /&gt;
		[1] = {},&lt;br /&gt;
		[2] = {required = true},&lt;br /&gt;
		[&amp;quot;sc&amp;quot;] = {},&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	args = require(&amp;quot;Module:parameters&amp;quot;).process(frame:getParent().args, params)&lt;br /&gt;
	self._info = {code = args[1], label = args[2]}&lt;br /&gt;
	&lt;br /&gt;
	self:initCommon()&lt;br /&gt;
	&lt;br /&gt;
	if not self._data then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function Category.new(info)&lt;br /&gt;
	for key, val in pairs(info) do&lt;br /&gt;
		if not (key == &amp;quot;code&amp;quot; or key == &amp;quot;label&amp;quot;) then&lt;br /&gt;
			error(&amp;quot;The parameter \&amp;quot;&amp;quot; .. key .. &amp;quot;\&amp;quot; was not recognized.&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local self = setmetatable({}, Category)&lt;br /&gt;
	self._info = info&lt;br /&gt;
	&lt;br /&gt;
	if not self._info.label then&lt;br /&gt;
		error(&amp;quot;No label was specified.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	self:initCommon()&lt;br /&gt;
	&lt;br /&gt;
	if not self._data then&lt;br /&gt;
		error(&amp;quot;The label \&amp;quot;&amp;quot; .. self._info.label .. &amp;quot;\&amp;quot; does not exist.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return self&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
export.new = Category.new&lt;br /&gt;
export.new_main = Category.new_main&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:initCommon()&lt;br /&gt;
	if self._info.code then&lt;br /&gt;
		self._lang = require(&amp;quot;Module:languages&amp;quot;).getByCode(self._info.code) or&lt;br /&gt;
			error(&amp;quot;The language code \&amp;quot;&amp;quot; .. self._info.code .. &amp;quot;\&amp;quot; is not valid.&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Convert label to lowercase if possible&lt;br /&gt;
	local lowercase_label = mw.getContentLanguage():lcfirst(self._info.label)&lt;br /&gt;
	&lt;br /&gt;
	if labels[lowercase_label] then&lt;br /&gt;
		self._info.label = lowercase_label&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	self._data = labels[self._info.label]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getInfo()&lt;br /&gt;
	return self._info&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getBreadcrumbName()&lt;br /&gt;
	return self._info.label&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getDataModule()&lt;br /&gt;
	return self._data[&amp;quot;edit&amp;quot;]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:canBeEmpty()&lt;br /&gt;
	if self._lang then&lt;br /&gt;
		return false&lt;br /&gt;
	else&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:isHidden()&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getCategoryName()&lt;br /&gt;
	if self._lang then&lt;br /&gt;
		return self._lang:getCode() .. &amp;quot;:&amp;quot; .. mw.getContentLanguage():ucfirst(self._info.label)&lt;br /&gt;
	else&lt;br /&gt;
		return mw.getContentLanguage():ucfirst(self._info.label)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getDescription()&lt;br /&gt;
	if self._lang then&lt;br /&gt;
		local ret = self._data[&amp;quot;description&amp;quot;]&lt;br /&gt;
		&lt;br /&gt;
		-- TODO: Should probably find a better way to do this&lt;br /&gt;
		descriptionFormats = {&lt;br /&gt;
			[&amp;quot;default&amp;quot;]					= &amp;quot;{{{langname}}} terms related to {{{label_lc}}}.&amp;quot;,&lt;br /&gt;
			[&amp;quot;default with capital&amp;quot;]	= &amp;quot;{{{langname}}} terms related to {{{label_uc}}}.&amp;quot;,&lt;br /&gt;
			[&amp;quot;default with the&amp;quot;]		= &amp;quot;{{{langname}}} terms related to the {{{label_uc}}}.&amp;quot;,&lt;br /&gt;
			[&amp;quot;default with the lower&amp;quot;]	= &amp;quot;{{{langname}}} terms related to the {{{label_lc}}}.&amp;quot;,&lt;br /&gt;
			[&amp;quot;default with topic&amp;quot;]		= &amp;quot;{{{langname}}} terms related to {{{label_lc}}} topics.&amp;quot;,&lt;br /&gt;
			[&amp;quot;default-set&amp;quot;]				= &amp;quot;{{{langname}}} terms for various {{{label_lc}}}.&amp;quot;,&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		ret = descriptionFormats[ret] or ret&lt;br /&gt;
		&lt;br /&gt;
		if ret then&lt;br /&gt;
			ret = ret:gsub(&amp;quot;{{{langname}}}&amp;quot;, self._lang:getCanonicalName())&lt;br /&gt;
			ret = ret:gsub(&amp;quot;{{{langcat}}}&amp;quot;, self._lang:getCategoryName())&lt;br /&gt;
			&lt;br /&gt;
			if ret:find(&amp;quot;{{{label_uc}}}&amp;quot;) then&lt;br /&gt;
				local label_entry_name = mw.getContentLanguage():ucfirst(self._info.label)&lt;br /&gt;
				local label_entry = mw.title.new(label_entry_name)&lt;br /&gt;
				&lt;br /&gt;
				if label_entry.exists then&lt;br /&gt;
					ret = ret:gsub(&amp;quot;{{{label_uc}}}&amp;quot;, &amp;quot;[[&amp;quot; .. label_entry_name .. &amp;quot;]]&amp;quot;)&lt;br /&gt;
				else&lt;br /&gt;
					ret = ret:gsub(&amp;quot;{{{label_uc}}}&amp;quot;, label_entry_name)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			if ret:find(&amp;quot;{{{label_lc}}}&amp;quot;) then&lt;br /&gt;
				local label_entry_name = mw.getContentLanguage():lcfirst(self._info.label)&lt;br /&gt;
				local label_entry = mw.title.new(label_entry_name)&lt;br /&gt;
				&lt;br /&gt;
				if label_entry.exists then&lt;br /&gt;
					ret = ret:gsub(&amp;quot;{{{label_lc}}}&amp;quot;, &amp;quot;[[&amp;quot; .. label_entry_name .. &amp;quot;]]&amp;quot;)&lt;br /&gt;
				else&lt;br /&gt;
					ret = ret:gsub(&amp;quot;{{{label_lc}}}&amp;quot;, label_entry_name)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		return ret&lt;br /&gt;
	else&lt;br /&gt;
		if not self._lang and ( self._info.label == &amp;quot;all topics&amp;quot; or self._info.label == &amp;quot;all sets&amp;quot; ) then&lt;br /&gt;
			return &amp;quot;This category applies to content and not to meta material about the Wiki.&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		local eninfo = mw.clone(self._info)&lt;br /&gt;
		eninfo.code = &amp;quot;en&amp;quot;&lt;br /&gt;
		local en = Category.new(eninfo)&lt;br /&gt;
		&lt;br /&gt;
		return&lt;br /&gt;
			&amp;quot;This category contains only other categories, no dictionary entries. Its subcategories are on the topic: &amp;quot; .. self._info.label .. &amp;quot;. They may be of two sorts:\n\n&amp;quot; ..&lt;br /&gt;
			&amp;quot;* Subcategories named like \&amp;quot;aa:&amp;quot; .. self._info.label .. &amp;quot; (with a prefixed language code) are categories of terms in specific languages. &amp;quot; ..&lt;br /&gt;
			&amp;quot;You may be interested especially in [[:Category:&amp;quot; .. en:getCategoryName() .. &amp;quot;]], for English terms.\n&amp;quot; ..&lt;br /&gt;
			&amp;quot;* Subcategories of this one named without the prefixed language code are further categories just like this one, but devoted to finer topics.&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getParents()&lt;br /&gt;
	local parents = self._data[&amp;quot;parents&amp;quot;]&lt;br /&gt;
	&lt;br /&gt;
	if not self._lang and ( self._info.label == &amp;quot;all topics&amp;quot; or self._info.label == &amp;quot;all sets&amp;quot; ) then&lt;br /&gt;
		return {{ name = &amp;quot;Category:Fundamental&amp;quot;, sort = self._info.label:gsub(&amp;quot;all &amp;quot;, &amp;quot;&amp;quot;) }}&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not parents or #parents == 0 then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	local is_set = false&lt;br /&gt;
	&lt;br /&gt;
	if self._info.label == &amp;quot;all sets&amp;quot; then&lt;br /&gt;
		is_set = true&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	for key, parent in ipairs(parents) do&lt;br /&gt;
		parent = mw.clone(parent)&lt;br /&gt;
		&lt;br /&gt;
		if type(parent) ~= &amp;quot;table&amp;quot; then&lt;br /&gt;
			parent = {name = parent}&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if not parent.sort then&lt;br /&gt;
			parent.sort = self._info.label&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if self._lang then&lt;br /&gt;
			parent.sort = parent.sort:gsub(&amp;quot;{{{langname}}}&amp;quot;, self._lang:getCanonicalName())&lt;br /&gt;
			parent.sort = parent.sort:gsub(&amp;quot;{{{langcat}}}&amp;quot;, self._lang:getCategoryName())&lt;br /&gt;
		elseif parent.sort:find(&amp;quot;{{{langname}}}&amp;quot;) or parent.sort:find(&amp;quot;{{{langcat}}}&amp;quot;) or parent.template == &amp;quot;langcatboiler&amp;quot; then&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if not self._lang then&lt;br /&gt;
			parent.sort = &amp;quot; &amp;quot; .. parent.sort&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if parent.name and parent.name:find(&amp;quot;^Category:&amp;quot;) then&lt;br /&gt;
			if self._lang then&lt;br /&gt;
				parent.name = parent.name:gsub(&amp;quot;{{{langname}}}&amp;quot;, self._lang:getCanonicalName())&lt;br /&gt;
				parent.name = parent.name:gsub(&amp;quot;{{{langcat}}}&amp;quot;, self._lang:getCategoryName())&lt;br /&gt;
			elseif parent.name:find(&amp;quot;{{{langname}}}&amp;quot;) or parent.name:find(&amp;quot;{{{langcat}}}&amp;quot;) or parent.template == &amp;quot;langcatboiler&amp;quot; then&lt;br /&gt;
				return nil&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if parent.name == &amp;quot;list of sets&amp;quot; then&lt;br /&gt;
				is_set = true&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			local pinfo = mw.clone(self._info)&lt;br /&gt;
			pinfo.label = parent.name&lt;br /&gt;
			&lt;br /&gt;
			if parent.template then&lt;br /&gt;
				parent.name = require(&amp;quot;Module:category tree/&amp;quot; .. parent.template).new(pinfo)&lt;br /&gt;
			else&lt;br /&gt;
				parent.name = Category.new(pinfo)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		table.insert(ret, parent)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not is_set and self._info.label ~= &amp;quot;list of topics&amp;quot; and self._info.label ~= &amp;quot;list of sets&amp;quot; then&lt;br /&gt;
		local pinfo = mw.clone(self._info)&lt;br /&gt;
		pinfo.label = &amp;quot;list of topics&amp;quot;&lt;br /&gt;
		table.insert(ret, {name = Category.new(pinfo), sort = (not self._lang and &amp;quot; &amp;quot; or &amp;quot;&amp;quot;) .. self._info.label})&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getChildren()&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function Category:getUmbrella()&lt;br /&gt;
	if not self._lang then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local uinfo = mw.clone(self._info)&lt;br /&gt;
	uinfo.code = nil&lt;br /&gt;
	return Category.new(uinfo)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Adminsuzy</name></author>
		
	</entry>
</feed>