มอดูล:category tree/poscatboiler/data/ยูนิโคด

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

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


local raw_categories = {}
local raw_handlers = {}



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


raw_categories["บล็อกยูนิโคด"] = {
	topright = "{{shortcut|CAT:UC}}",
	description = "Categories with blocks of particular Unicode characters.",
	parents = {
		"มูลฐาน",
		"หมวดหมู่:ภาคผนวก",
	},
}

raw_categories["บล็อกยูนิโคดแบ่งตามจำนวนรายการ"] = {
	description = "Categories that group blocks of Unicode characters by the number of characters in those blocks.",
	parents = {
		{name = "บล็อกยูนิโคด", sort = " "},
	},
}

for _, block in ipairs({
	{num = "0", desc = "no other", sort = "*000"},
	{num = "1–10", desc = "1 to 10", sort = "*001"},
	{num = "11–50", desc = "11 to 50", sort = "*011"},
	{num = "51–100", desc = "51 to 100", sort = "*051"},
	{num = "101+", desc = "at least 101", sort = "*101"},
}) do
raw_categories["บล็อกยูนิโคดที่มี " .. block.num .. " รายการ"] = {
	description = "Unicode block categories containing 1 appendix + " .. block.desc .. " entries.",
	parents = {{name = "บล็อกยูนิโคดแบ่งตามจำนวนรายการ", sort = block.sort}},
	breadcrumb = block.num,
}
end



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


table.insert(raw_handlers, function(data)
	local block = mw.ustring.match(data.category, "^บล็อก (.*)$")
	if block then
		local pages_in_category = mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "pages")
		local entry_bucket
		-- At least 1 page is the appendix for the current Unicode block.
		if pages_in_category == 1 then
			entry_bucket = "0"
		elseif pages_in_category <= 11 then
			entry_bucket = "1–10"
		elseif pages_in_category <= 51 then
			entry_bucket = "11–50"
		elseif pages_in_category <= 101 then
			entry_bucket = "51–100"
		else
			entry_bucket = "101+"
		end
		return {
			description = "Entries for characters in the '''[[ภาคผนวก:ยูนิโคด/" .. block .. "|" .. block .. "]]''' block, " ..
			"as categorized by the character boxes.",
			additional = "Some entries may define characters from multiple Unicode codepoints at once, so the page title " ..
			"could be an entry that is not from this block.",
			breadcrumb = block,
			parents = {
				"บล็อกยูนิโคด",
				"บล็อกยูนิโคดที่มี " .. entry_bucket .. " รายการ",
			},
		}
	end
end)


return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}