Модул:category tree/poscatboiler/data/wiktionary

Документацију овог модула можете да направите на страници Модул:category tree/poscatboiler/data/wiktionary/док

local raw_categories = {}
local raw_handlers = {}


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


raw_categories["Викиречник"] = {
	description = "High level category for material about Wiktionary and its operation.",
	parents = {
		"Почетак",
	},
}

raw_categories["Викиречник корисници"] = {
	description = "Pages listing Wiktionarians according to their user rights and categories listing Wiktionarians according to their linguistic and coding abilities.",
	breadcrumb = "Корисници",
	additional = "For an automatically generated list of all users, see [[Special:ListUsers]].",
	parents = {
		{name = "Викиречник", sort = "Корисници"},
	},
}

raw_categories["User languages"] = {
	description = "Categories listing Wiktionarians according to their linguistic abilities.",
	parents = {
		"Викиречник корисници",
		"Категорија:Wiktionary multilingual issues",
	},
}


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


table.insert(raw_handlers, function(data)
	local langcode, level
	langcode = data.category:match("^Корисник ([a-z][a-z][a-z]?)$")
	if not langcode then
		langcode = data.category:match("^Корисник ([a-z][a-z][a-z]?%-[a-zA-Z-]+)$")
	end
	if not langcode then
		langcode, level = data.category:match("^Корисник ([a-z][a-z][a-z]?)%-([0-5N])$")
	end
	if not langcode then
		langcode, level = data.category:match("^Корисник ([a-z][a-z][a-z]?%-[a-zA-Z-]+)%-([0-5N])$")
	end
	if not langcode then
		return
	end
	local lang = require("Модул:languages").getByCode(langcode, nil, "allow etym")
	if not lang then
		return
	end
	local langname = lang:getCanonicalName()

	local params = {
		text = {},
		verb = {},
		standard = {type = "boolean"},
	}

	local args = require("Модул:parameters").process(data.args, params)

	local level_params = {
		["0"] = {
			leftcolor = "#FFB3B3",
			rightcolor = "#FFE0E8",
			en = "These users do not understand LANG (or understand it with considerable difficulty).",
		},
		["1"] = {
			leftcolor = "#C0C8FF",
			rightcolor = "#F0F8FF",
			en = "These users are able to contribute with a '''basic''' level of LANG.",
		},
		["2"] = {
			leftcolor = "#77E0E8",
			rightcolor = "#D0F8FF",
			en = "These users are able to contribute with an '''intermediate''' level of LANG.",
		},
		["3"] = {
			leftcolor = "#99B3FF",
			rightcolor = "#E0E8FF",
			en = "These users are able to contribute with an '''advanced''' level of LANG.",
		},
		["4"] = {
			leftcolor = "#CCCC00",
			rightcolor = "#FFFF99",
			en = "These users speak LANG at a '''near native''' level.",
		},
		["5"] = {
			leftcolor = "#FF5E5E",
			rightcolor = "#FF8080",
			en = "These users are able to contribute with a '''professional''' level of LANG.",
		},
		["N"] = {
			leftcolor = "#6EF7A7",
			rightcolor = "#C5FCDC",
			en = "These users are '''native''' speakers of LANG.",
		},
	}

	local parts = {}
	local function ins(txt)
		table.insert(parts, txt)
	end
	-- Insert text, appropriately script-tagged, unless already script-tagged (we check for '<span'), in which case we
	-- insert it directly. Also handle <<...>> in text and convert to bolded link to parent category.
	local function ins_and_wrap(txt)
		if not txt then
			return
		end
		-- Substitute <<...>> (where ... is supposed to be the native rendering of the language) with a link to the
		-- top-level 'User CODE' category (e.g. [[:Category:User fr]] or [[:Category:User fr-CA]]) if we're in a
		-- sublevel category, or to the top-level language category (e.g. [[:Category:French language]] or
		-- [[:Category:Canadian English]]) if we're in a top-level 'User CODE' category.
		txt = txt:gsub("<<(.-)>>", function(inside)
			if level then
				return ("'''[[:Категорија:User %s|%s]]'''"):format(langcode, inside)
			else
				return ("'''[[:Категорија:%s|%s]]'''"):format(lang:getCategoryName(), inside)
			end
		end)
		if txt:find("<span") then
			ins(txt)
		else
			ins(require("Модул:script utilities").tag_text(txt, lang))
		end
	end

	if level then
		local params = level_params[level]

		ins(('<div style="float:left;border:solid %s 1px;margin:1px">'):format(params.leftcolor))
		ins(('<table cellspacing="0" style="width:238px;background:%s"><tr>'):format(params.rightcolor))
		ins(('<td style="width:45px;height:45px;background:%s;text-align:center;font-size:14pt">'):format(params.leftcolor))
		ins(("'''%s-%s'''</td>"):format(langcode, level))
		ins('<td style="font-size:8pt;padding:4pt;line-height:1.25em">')
		ins_and_wrap(args.text)
		if args.standard ~= false then
			if args.text then
				ins("<hr />")
			end
			local langcat = ("'''[[:Категорија:Корисник %s|%s]]'''"):format(langcode, langname)
			local en = params.en:gsub("LANG", langcat)
			ins(en)
		end
		ins('</td></tr></table></div><br clear="left">')
		return {
			description = table.concat(parts),
			additional = ("To be included on this list, add {{tl|Babel|%s}} to your user page. Complete instructions are " ..
				"available at [[Wiktionary:Babel]]."):format(level == "N" and langcode or ("%s-%s"):format(langcode, level)),
			breadcrumb = "Level " .. level,
			parents = {
				{name = ("Корисник %s"):format(langcode), sort = level},
			},
		}, true
	else
		ins('<div style="float:left;border:solid #99b3ff 1px;margin:1px;">\n')
		ins('{| cellspacing="0" style="width:260px;background:#e0e8ff;"\n')
		ins('| style="width:45px;height:45px;background:#99b3ff;text-align:center;font-size:14pt;" | ')
		ins(("'''%s'''\n"):format(langcode))
		ins('| style="font-size:8pt;padding:4pt;line-height:1.25em;text-align:center;" | ')
		ins_and_wrap(args.text)
		if args.standard ~= false then
			if args.text then
				ins("<hr />")
			end
			ins(("These users %s '''[[%s]]'''.\n"):format(args.verb or "speak", langname))
		end
		ins('|}</div><br clear="all">')
		local parents = {
			{name = "User languages", sort = langname},
			{name = lang:getCategoryName(), sort = "user"},
		}
		if lang:hasType("etymology-only") then
			table.insert(parents, {name = lang:getNonEtymological():getCategoryName(), sort = " " .. langname})
		end

		return {
			description = table.concat(parts),
			breadcrumb = langname,
			parents = parents,
		}, true
	end
end)


return {RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers}