Module:category tree/word of the day


This data submodule defines part of Wiktionary's category structure.

For an introduction to the category tree system and a description of how to add or modify categories, see Module:category tree/documentation.


local raw_categories = {}
local raw_handlers = {}

local insert = table.insert

-----------------------------------------------------------------------------
--																		 --
--							  RAW CATEGORIES							 --
--																		 --
-----------------------------------------------------------------------------


raw_categories["Words of the day"] = {
	description = "This is a grouping category to weed out [[WT:WOTD|WOTD]] entries from the Wiktionary: namespace, in particular, for [[WT:RP]].",
	parents = "Category:Wiktionary tracking categories",
}

raw_categories["Word of the day archive"] = {
	description = "Entries previously selected as [[WT:WOD|word of the day]].",
	parents = "Words of the day",
	breadcrumb = "English",
	hidden = true,
}

raw_categories["Foreign word of the day archive"] = {
	description = "Entries previously selected as [[WT:FW|foreign word of the day]].",
	parents = "Words of the day",
	breadcrumb = "foreign",
	hidden = true,
}

raw_categories["Foreign words of the day by language"] = {
	description = "Categories with foreign words of day in various languages.",
	additional = "{{{umbrella_msg}}}",
	parents = "Foreign word of the day archive",
	breadcrumb = "by language",
}



-----------------------------------------------------------------------------
--																		 --
--								RAW HANDLERS							 --
--																		 --
-----------------------------------------------------------------------------

-- WOTD by year and month
insert(raw_handlers, function(data)
	local year, month = data.category:match("^Word of the day archive/(%d+)/(%w+)$")
	if not year then
		year = data.category:match("^Word of the day archive/(%d+)$")
		if not year then
			return
		end
		return {
			breadcrumb = year,
			description = "Words of the day from " .. year .. ".",
			parents = {
				{name = "Word of the day archive", sort = year},
			},
			hidden = true,
		}
	else
		return {
			breadcrumb = month,
			description = "Words of the day from " .. month .. " of " .. year .. ".",
			parents = {
				{name = "Word of the day archive/" .. year, sort = month},
			},
			hidden = true,
		}
	end
end)

-- FWOTD by year and month
insert(raw_handlers, function(data)
	local year, month = data.category:match("^Foreign word of the day archive/(%d+)/(%w+)$")
	if not year then
		year = data.category:match("^Foreign word of the day archive/(%d+)$")
		if not year then
			return
		end
		return {
			breadcrumb = year,
			description = "Foreign words of the day from " .. year .. ".",
			parents = {
				{name = "Foreign word of the day archive", sort = year},
			},
			hidden = true,
		}
	else
		return {
			breadcrumb = month,
			description = "Foreign words of the day from " .. month .. " of " .. year .. ".",
			parents = {
				{name = "Foreign word of the day archive/" .. year, sort = month},
			},
			hidden = true,
		}
	end
end)

-- FWOTD by language and year
insert(raw_handlers, function(data)
	local langname, year = data.category:match("^Foreign words of the day in ([^/]+)/(%d+)$")
	if not langname then
		langname = data.category:match("^Foreign words of the day in ([^/]+)$")
	end
	if not (langname and langname ~= "English") then
		return
	end
	
	local lang = require("Module:languages").getByCanonicalName(langname, true)
	
	local parents
	local description
	local breadcrumb
	
	if year then
		description = "Foreign words of the day in " .. lang:makeCategoryLink() .. " from " .. year .. "."
		parents = {
			{name = "Foreign words of the day in " .. langname, sort = year},
			{name = "Foreign word of the day archive/" .. year, sort = langname},
		}
		breadcrumb = year
	else
		description = "Foreign words of the day in " .. lang:makeCategoryLink() .. "."
		parents = {
			{name = "Foreign words of the day by language", sort = langname},
			lang:getCategoryName(),
		}
		breadcrumb = langname
	end
	
	return {
		lang = lang:getCode(),
		description = description,
		parents = parents,
		breadcrumb = breadcrumb,
		hidden = true,
	}
end)


return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}
Category:Category tree data modules