模組:Category tree/poscatboiler/data/unicode/sandbox


此數據子模塊定義了維基詞典分類結構的一部分。

關於poscatboiler系統的介紹以及如何添加或更改分類,請參見Module:category tree/poscatboiler/data/documentation


local raw_categories = {}
local raw_handlers = {}



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


raw_categories["Unicode區段"] = {
	intro = "{{shortcut|CAT:UC}}",
	description = "含有各個Unicode區段的分類。",
	parents = {
		"分类",
		"Category:附錄",
	},
}

raw_categories["各詞條數量Unicode區段"] = {
	description = "按區段中的字符數對Unicode區段進行分組的分類。",
	parents = {
		{name = "Unicode區段", sort = " "},
	},
}

for _, block in ipairs({
	{num = "0", desc = "0個", sort = "*000"},
	{num = "1-10", desc = "1至10個", sort = "*001"},
	{num = "11-50", desc = "11至50個", sort = "*011"},
	{num = "51-100", desc = "51至100個", sort = "*051"},
	{num = "超過100", desc = "至少101個", sort = "*101"},
}) do
raw_categories["擁有" .. block.num .. "個詞條的Unicode區段"] = {
	description = "本分類收錄了擁有一篇附錄及" .. block.desc .. "字元詞條的Unicode區段。",
	parents = {{name = "各詞條數量Unicode區段", sort = block.sort}},
	breadcrumb = block.num,
}
end



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


table.insert(raw_handlers, function(data)
	local block = data.category:match("^(.*)區段")
	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 = "超過100"
		end
		return {
			description = "此分類包含了'''[[Appendix:Unicode/" .. block .. "|" .. block .. "]]'''中的字符的詞條。",
			additional = "由於一些詞條可能一次定義了來自多個Unicode代碼點的字符," ..
			"因此頁面標題可能並不是來自此區段的詞條。",
			breadcrumb = block,
			parents = {
				"Unicode區段",
				"擁有" .. entry_bucket .. "個詞條的Unicode區段",
			},
		}
	end
end)


return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}