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 labels = {}
local raw_categories = {}
local raw_handlers = {}



-----------------------------------------------------------------------------
--                                                                         --
--                                  LABELS                                 --
--                                                                         --
-----------------------------------------------------------------------------
-- labels ทั้งหมดจะตามด้วยภาษา... ไม่เหมือนกับ raw_categories ที่ไม่มีอะไรเติม


labels["มอดูล"] = {
	description = "{{{langname}}} [[Wiktionary:Modules|modules]], which contain Lua code to create and manage entries.",
	umbrella = {
		parents = {{name = "มอดูล", sort = " "}},
		breadcrumb = "แบ่งตามภาษา",
	},
	parents = {{name = "{{{langcat}}}", raw = true}},
}
labels["modules"] = labels["มอดูล"]

labels["มอดูลข้อมูล"] = {
	description = "{{{langname}}} [[Wiktionary:Modules|modules]] containing data used by other modules.",
	umbrella = {
		parents = {{name = "มอดูลข้อมูล", sort = " "}},
		breadcrumb = "แบ่งตามภาษา",
	},
	breadcrumb = "ข้อมูล",
	parents = {"มอดูล"},
}
labels["data modules"] = labels["มอดูลข้อมูล"]

labels["dialect synonyms data modules"] = {
	description = "{{{langname}}} [[Wiktionary:Modules|modules]] containing data used by {{tl|dialect synonyms}}.",
	umbrella = {
		parents = {{name = "Dialect synonyms data modules", sort = " "}},
		breadcrumb = "แบ่งตามภาษา",
	},
	breadcrumb = "dialect synonyms",
	parents = {"มอดูลข้อมูล"},
}

labels["มอดูลการผันรูป"] = {
	description = "{{{langname}}} [[inflection]] [[Wiktionary:Modules|modules]], which contain Lua code for generating conjugation and declension tables.",
	umbrella = {
		parents = {{name = "มอดูลการผันรูป", sort = " "}},
		breadcrumb = "แบ่งตามภาษา",
	},
	breadcrumb = "การผันรูป",
	parents = {"มอดูล"},
}

labels["มอดูลทดสอบ"] = {
	description = "{{{langname}}} [[testcase]] [[Wiktionary:Modules|modules]], which contain Lua code for testing other modules.",
	umbrella = {
		parents = {{name = "มอดูลทดสอบ", sort = " "}},
		breadcrumb = "แบ่งตามภาษา",
	},
	breadcrumb = "ทดสอบ",
	parents = {"มอดูล"},
}



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

--[=[
Correctly defining a new module type here:
1. The breadcrumb generally does not need to be given because there is code at the bottom of this file
   to generate the breadcrumb in a smart fashion by chopping off a suffix derived from the parent or any of
   its ancestors.
2. Module types can be nested under other module types, but also list them directly under 'Modules' as a
   secondary parent. (This violates a principle of non-duplication of categories but makes it much easier to
   locate a given module type.)
]=]

raw_categories["มอดูล"] = {
	description = "This is a general holder category for modules.",
	additional = "For more information on what modules are and how they work, see [[Wiktionary:Scribunto]]. For a complete list of all modules, see [[Special:PrefixIndex/Module:|here]].",
	parents = {"หมวดหมู่:วิกิพจนานุกรม"},
}

raw_categories["มอดูลที่ไม่จัดหมวดหมู่"] = {
	description = "Uncategorized modules.",
	additional = "Modules are placed here by [[Module:documentation]] under certain circumstances. See the documentation of that module for more info.",
	parents = { {name = "มอดูล", sort = " "} },
}

raw_categories["มอดูลภาคผนวก"] = {
	preceding = "{{also|:Category:Appendix templates}}",
	description = "Modules with functions that generate content for or extract information from pages in the Appendix namespace.",
	parents = { "มอดูล" },
}

raw_categories["Bot support modules"] = {
	description = "Modules for supporting individual bot accounts.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลหมวดหมู่"] = {
	preceding = "{{also|:Category:Categorization templates|:Category:Category templates}}",
	description = "Modules for adding categories to pages or generating the description and subcategories of category pages.",
	parents = { "มอดูล" },
}

raw_categories["Character info modules"] = {
	preceding = "{{also|:Category:Character info templates}}",
	description = "Modules containing information on individual characters, or containing functions generating such information.",
	parents = { "มอดูล" },
}

raw_categories["Character insertion modules"] = {
	preceding = "{{also|:Category:Character insertion templates}}",
	description = "Modules that implement templates that provide easier ways to type characters that are not found in most keyboard layouts.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["Collections modules"] = {
	description = "Modules containing functions used to implement collections (arrays, maps, etc.).",
	parents = { "มอดูลอรรถประโยชน์", "มอดูล" },
}

raw_categories["มอดูลข้อมูล"] = {
	description = "Modules that do not contain functions, but only export a table of data that is used by other modules. Modules that are in this category should be imported using <code>mw.loadData</code> rather than <code>require</code>.",
	additional = "Modules that are in this category should be imported using <code>mw.loadData</code> rather than <code>require</code>.",
	parents = { "มอดูล" },
}

raw_categories["Character insertion data modules"] = {
	preceding = "{{also|:Category:Character insertion templates}}",
	description = "Modules containing data for use by {{temp|chars}}.",
	parents = { "มอดูลข้อมูล", "Character insertion modules" },
}

raw_categories["Dialect synonyms data modules"] = {
	preceding = "{{also|:Category:Character insertion templates}}",
	description = "Modules containing data for use by {{tl|dialect synonyms}}.",
	parents = { "มอดูลข้อมูล" },
}

raw_categories["Date modules"] = {
	description = "Modules that implement functionality to convert or otherwise manipulate dates in various calendar systems.",
	parents = { "มอดูลอรรถประโยชน์", "มอดูล" },
}

raw_categories["Debugging modules"] = {
	description = "Modules used for debugging.",
	additional = "Some should only be used in sandbox modules or when using the " ..
	"[[mw:Extension:TemplateSandbox|{{MediaWiki:Templatesandbox-editform-legend}}]] button in the edit page of modules and templates.",
	parents = { "มอดูล" },
}

raw_categories["Definition modules"] = {
	preceding = "{{also|:Category:Definition templates}}",
	description = "Modules that implement templates used in [[Wiktionary:Glossary#definition line|definition lines]] of entries.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลล้าสมัย"] = {
	description = "Modules that should not be used, as their functions are performed by newer modules.",
	parents = { "มอดูล", "Category:Wiktionary maintenance" },
}

raw_categories["Discussion modules"] = {
	preceding = "{{also|:Category:Discussion templates}}",
	description = "Modules concerning discussion pages.",
	parents = { "มอดูล" },
}

raw_categories["Display text-generating modules"] = {
	description = "Modules that are used to generate display text.",
	additional = "Display text determines what is shown to the reader. In some languages it must be normalized, " ..
	"due to common errors caused by confusable characters, or so as to ensure a consistent display format.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลเอกสารการใช้งาน"] = {
	preceding = "{{also|:Category:Documentation templates}}",
	description = "Modules for generating documentation pages.",
	parents = { "มอดูล" },
}

raw_categories["Encoding modules"] = {
	description = "Modules for converting between different textual encodings.",
	parents = { "มอดูลอรรถประโยชน์", "มอดูล" },
}

raw_categories["Entry-generating modules"] = {
	preceding = "{{also|:Category:Entry templates}}",
	description = "Modules with functions that are used to generate new entries.",
	parents = { "มอดูล" },
}

raw_categories["Entry name-generating modules"] = {
	description = "Modules that generate entry names, which typically have certain diacritics stripped compared with the form in links and headwords.",
	parents = { "มอดูล" },
}

raw_categories["External link modules"] = {
	preceding = "{{also|:Category:External link templates}}",
	description = "Modules that are used in [[:Category:External link templates|external link templates]], i.e. which link to websites outside of the MediaWiki Foundation purview.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลรากศัพท์"] = {
	preceding = "{{also|:Category:Etymology templates}}",
	description = "Modules that implement templates that define the etymology of entries.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["Form-of modules"] = {
	preceding = "{{also|:Category:Form-of templates}}",
	description = "Modules that generate the definition line of non-lemma forms, e.g. verb forms and noun forms.",
	parents = { "Definition modules", "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลบรรทัดคำหลัก"] = {
	preceding = "{{also|:Category:Headword-line templates}}",
	description = "Modules that support [[:Category:Headword-line templates by language|headword-line templates]] for a specific language.",
	additional = "See also [[:Category:Headword-line templates]].",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลการผันรูป"] = {
	description = "Modules used to support [[:Category:Inflection-table templates by language|inflection templates]] for a specific language.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลลิงก์ภายใน"] = {
	preceding = "{{also|:Category:Internal link templates}}",
	description = "Modules that are used in [[:Category:Internal link templates|internal link templates]], i.e. which link between Wiktionary entries.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["Interwiki modules"] = {
	preceding = "{{also|:Category:Interwiki templates}}",
	description = "Modules that are used in [[:Category:Interwiki templates|interwiki templates]], i.e. which link to other MediaWiki projects.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["JSON-generating modules"] = {
	description = "Modules with functions that generate data in JSON format.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลภาษาและอักษร"] = {
	description = "Modules that process language and script codes and return data on them.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลรายชื่อ"] = {
	preceding = "{{also|:Category:List templates}}",
	description = "Modules that generate lists, tables or tree diagrams of entries or other structured data.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["Maintenance modules"] = {
	preceding = "{{also|:Category:Maintenance templates}}",
	description = "Modules that implement templates used for maintaining entries.",
	additional = "Examples are cleanup templates (e.g. {{tl|attention}}), deletion templates (e.g. {{tl|rfd}}) and " ..
	"verification templates (e.g. {{tl|rfv}}).",
	parents = { "มอดูล" },
}

raw_categories["Number modules"] = {
	preceding = "{{also|:Category:Number templates}}",
	description = "Modules that handle conversion and/or formatting of numbers and numerals in various representations.",
	parents = { "มอดูลอรรถประโยชน์", "มอดูล" },
}

raw_categories["Page generation modules"] = {
	description = "Modules that generate parts of a mainspace page (e.g. headword line, definition, inflection, links, etc.).",
	parents = { "มอดูล" },
}

raw_categories["Parameter parsing modules"] = {
	description = "Modules containing functions used to parse template parameters.",
	parents = { "มอดูลอรรถประโยชน์", "มอดูล" },
}

raw_categories["มอดูลการออกเสียง"] = {
	preceding = "{{also|:Category:Pronunciation templates}}",
	description = "Modules that implement templates used to create the language-specific pronunciation of entries.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลทดสอบการออกเสียง"] = {
	description = "Modules used to test other pronunciation modules.",
	parents = { "มอดูลทดสอบ", {name = "มอดูลการออกเสียง", sort = "ทดสอบ"} },
}

raw_categories["Quotation and usage example modules"] = {
	description = "Modules that implement templates used to format quotations and usage examples.",
	parents = { "Definition modules", "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลการอ้างอิง"] = {
	preceding = "{{also|:Category:Reference templates}}",
	description = "Modules that are used for [[:Category:Reference templates|reference templates]].",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["มอดูลกระบะทราย"] = {
	description = "Test versions of modules intended for production use.",
	parents = { "มอดูล" },
}

raw_categories["Semantic relation modules"] = {
	preceding = "{{also|:Category:Semantic relation templates}}",
	description = "Modules that implement templates used to indicate other terms semantically related to a " ..
	"particular sense, e.g. [[synonym]]s or [[antonym]]s.",
	parents = { "Page generation modules", "มอดูล" },
}

raw_categories["Sortkey-generating modules"] = {
	description = "Modules that generate sortkeys, which determine the order of entry names in categories.",
	parents = { "มอดูล" },
}

raw_categories["String modules"] = {
	description = "Modules containing functions used to manipulate strings.",
	parents = { "มอดูลอรรถประโยชน์", "มอดูล" },
}

raw_categories["Swadesh modules"] = {
	description = "Modules containing [[Swadesh list]]s.",
	parents = { "มอดูล" },
}

raw_categories["Template interface modules"] = {
	description = "Modules whose purpose is to provide an interface between templates and the functions of a module.",
	additional = "They are usually named <code>.../templates</code>, and the functions present within them usually all " ..
	"have only a \"frame\" parameter.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลทดสอบ"] = {
	description = "Modules used to test other modules.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลทดสอบที่มีความขัดข้อง"] = {
	description = "Modules which contain failures in their unit tests.",
	additional = "This category is added automatically by [[Module:UnitTests]] when a test case fails.",
	parents = { "มอดูลทดสอบ" },
}

raw_categories["มอดูลติดตาม"] = {
	description = "Modules that add tracking templates.",
	parents = { "Debugging modules", "มอดูล" },
}

raw_categories["มอดูลการถอดอักษร"] = {
	description = "Modules that automatically convert text in one script to another.",
	additional = "Most of them convert non-Latin scripts to Latin (romanisation/romanization), and are used by " ..
	"templates or modules to generate transliteration of text that is tagged with a particular language. Each " ..
	"language's transliteration module is specified in its data table (for which, see the category {{catlink|Language data modules}}).",
	parents = { "มอดูล" },
}

raw_categories["มอดูลทดสอบการถอดอักษร"] = {
	description = "Modules used to test other transliteration modules.",
	parents = { "มอดูลทดสอบ", {name = "มอดูลการถอดอักษร", sort = "ทดสอบ"} },
}

raw_categories["มอดูลไม่ได้ใช้"] = {
	description = "Unused modules.",
	parents = { "มอดูล" },
}

raw_categories["มอดูลกระบะทรายของผู้ใช้"] = {
	description = "Modules that are for personal use and testing by individual editors.",
	additional = "These should all begin with <code>User:</code> followed by the user's name. If several " ..
	"sandbox modules are needed by a single user, subpages can be created. These modules should not be used in real " ..
	"Wiktionary content pages, as all content on those pages should be editable by anyone and, if necessary, edit protected.",
	parents = { "มอดูลกระบะทราย", "มอดูล" },
}

raw_categories["มอดูลอรรถประโยชน์"] = {
	description = "Modules that serve some sort of utility purpose in various entries.",
	additional = "Avoid categorizing directly into this category, but use one of the more specific (and semantically " ..
	"well-defined) module categories. Note also that modules used by multiple languages should go directly in this " ..
	"category if necessary, while modules only used by one language should be in [[:Category:Language-specific utility modules]].",
	parents = { "มอดูล" },
}

raw_categories["มอดูลอรรถประโยชน์เฉพาะภาษา"] = {
	description = "Modules that deal with several utilities needed by a certain language.",
	additional = "Usually their names end with {{cd|-utilities}} or {{cd|-common}} (preceded by the language code), " ..
	"although more specific utility modules that one language uses may reside here as well. If a utility is used by " ..
	"many languages, it should be in [[:Category:มอดูลอรรถประโยชน์]].",
	parents = {{name = "มอดูลอรรถประโยชน์", sort = " "}},
}

raw_categories["Vote modules"] = {
	description = "Modules used to manage Wiktionary votes.",
	parents = { "มอดูล" },
}

raw_categories["Wikitext parsing modules"] = {
	description = "Modules that contain functions that grab the wikitext of a page and get information from it by " ..
	"performing string operations on it.",
	parents = { "มอดูล" },
}

-- Don't modify `raw_categories` while processing it, or items may be skipped.
local new_cats = {}
for raw_cat, obj in pairs(raw_categories) do
	local by_script = raw_cat .. "แบ่งตามอักษร"
	if raw_cat ~= "มอดูล" and raw_cat ~= "มอดูลข้อมูล" and not raw_categories[by_script] then
		new_cats[by_script] = {
			description = raw_cat .. ", categorized by the script they operate on or with.",
			additional = raw_cat .. " are " .. mw.getContentLanguage():lcfirst(obj.description),
			breadcrumb = "แบ่งตามอักษร",
			parents = {{name = raw_cat, sort = " "}},
		}
	end
end
for new_cat, obj in pairs(new_cats) do
	raw_categories[new_cat] = obj
end


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


for _, mod_type in ipairs { "Entry name-generating", "Sortkey-generating", "การถอดอักษร" } do --เปลี่ยนชื่อตามข้างบน
	table.insert(raw_handlers, function(data)
		local count, languages = data.category:match(("^%s modules used by ([0-9]+) (languages?)$"):format(
			-- need to escape the hyphen in 'Entry name-generating' and 'Sortkey-generating'
			require("Module:string utilities").pattern_escape(mod_type)))
		if count then
			return {
				description = data.category .. ".",
				breadcrumb = "used by " .. count .. " " .. languages,
				parents = {
					{ name = "มอดูล" .. mod_type, sort = count },
				},
			}
		end
	end)
end


-- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) from the end of the label, if possible.
for key, data in pairs(raw_categories) do
	if not data.breadcrumb then
		local parent = data.parents[1]
		while true do
			if type(parent) == "string" then
				local parent_re = " " .. require("Module:string utilities").pattern_escape(mw.getContentLanguage():lcfirst(parent)) .. "$"
				if key:find(parent_re) then
					data.breadcrumb = key:gsub(parent_re, "")
					break
				end
				if raw_categories[parent] then
					parent = raw_categories[parent].parents[1]
				else
					break
				end
			else
				break
			end
		end
	end
end


return {LABELS = labels, RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}