Modul:category tree/langcatboiler

Üdvözlöm, Ön a Modul:category tree/langcatboiler szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:category tree/langcatboiler szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:category tree/langcatboiler szót egyes és többes számban mondani. Minden, amit a Modul:category tree/langcatboiler szóról tudni kell, itt található. A Modul:category tree/langcatboiler szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:category tree/langcatboiler és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:category tree/langcatboiler/doc lapon tudod dokumentálni

local export = {}

local function linkbox(lang, setwiki, setsister, entryname)
	local wiktionarylinks = "''None.''"
	
	if #lang:getWikimediaLanguages() > 0 then
		wiktionarylinks = {}
		
		for _, wikimedialang in ipairs(lang:getWikimediaLanguages()) do
			table.insert(wiktionarylinks,
				(wikimedialang:getCanonicalName() ~= lang:getCanonicalName() and "(''" .. wikimedialang:getCanonicalName() .. "'') " or "") ..
				"''']'''")
		end
		
		wiktionarylinks = table.concat(wiktionarylinks, "<br/>")
	end
	
	return [=[<div style="clear: right; border: solid #aaa 1px; margin: 1 1 1 1; background: #f9f9f9; width: 270px; padding: 5px; margin: 5px; text-align: left; float: right">
<div style="text-align: center; margin-bottom: 10px; margin-top: 5px">''']=] .. lang:getCategoryName() .. [=['''</div>

{| style="font-size: 90%; background: #f9f9f9;"
|-
| style="vertical-align: middle; height: 35px; width: 35px;" | ]
|| '']=] .. lang:getCategoryName() .. =] .. (#lang:getWikimediaLanguages() > 1 and "s" or "") .. [=[ of Wiktionary''
|-
| colspan="2" style="padding-left: 10px; border-bottom: 1px solid lightgray;" | ]=] .. wiktionarylinks .. [=[

|-
| style="vertical-align: middle; height: 35px" | ]
|| ''Wikipedia article about ]=] .. lang:getCategoryName() .. [=[''
|-
| colspan="2" style="padding-left: 10px; border-bottom: 1px solid lightgray;" | ]=] .. (setwiki == "-" and "''None.''" or "''']'''") .. [=[

|-
| style="vertical-align: middle; height: 35px" | ]
|| ''Links related to ]=] .. lang:getCategoryName() .. [=[ in sister projects at Wikimedia Commons''
|-
| colspan="2" style="padding-left: 10px; border-bottom: 1px solid lightgray;" | ]=] .. (setsister == "-" and "''None.''" or "''']'''") .. [=[

|-
| style="vertical-align: middle; height: 35px" | ]
|| ]=] .. lang:getCategoryName() .. [=[ considerations
|-
| colspan="2" style="padding-left: 10px; border-bottom: 1px solid lightgray;" | '''=] .. lang:getCanonicalName() .. ]'''
|-
| style="vertical-align: middle; height: 35px" | ]
|| ]=] .. lang:getCategoryName() .. [=[ index
|-
| colspan="2" style="padding-left: 10px; border-bottom: 1px solid lightgray;" | '''=] .. lang:getCanonicalName() .. ]'''
|-
| style="vertical-align: middle; height: 35px" | ]
|| ]=] .. lang:getCategoryName() .. [=[ entry
|-
| colspan="2" style="padding-left: 10px;" | ''']=] .. require("Module:links").full_link({lang = require("Module:languages").getByCode("en"), term = entryname or lang:getCanonicalName()}) .. [=['''
|}
</div>]=]
end

-- Should perhaps use wiki syntax.
local function infobox(lang)
	local ret = {}
	
	table.insert(ret, "<table class=\"wikitable\">\n")
	table.insert(ret, "<tr>\n<th colspan=\"2\" class=\"plainlinks\"></th>\n</tr>\n")
	table.insert(ret, "<tr>\n<th>Canonical name</th><td>" .. lang:getCanonicalName() .. "</td>\n</tr>\n")
	
	if lang:getOtherNames() then
		local names = {}
		
		for _, name in ipairs(lang:getOtherNames()) do
			table.insert(names, "<li>" .. name .. "</li>")
		end
		
		if #names > 0 then
			table.insert(ret, "<tr>\n<th>Other names</th><td>" .. table.concat(names, "\n") .. "</td>\n</tr>\n")
		end
	end
	
	table.insert(ret, "<tr>\n<th>]</th><td><code>" .. lang:getCode() .. "</code></td>\n</tr>\n")
	table.insert(ret, "<tr>\n<th>]</th>\n")
	
	local fam = lang:getFamily()
	
	if not fam then
		table.insert(ret, "<td>unclassified</td>")
	elseif fam:getCode() == "qfa-iso" then
		table.insert(ret, "<td>]</td>")
	elseif fam:getCode() == "qfa-mix" then
		table.insert(ret, "<td>]</td>")
	elseif fam:getCode() == "sgn" then
		table.insert(ret, "<td>]</td>")
	elseif fam:getCode() == "crp" then
		table.insert(ret, "<td>]</td>")
	elseif fam:getCode() == "art" then
		table.insert(ret, "<td>]</td>")
	else
		table.insert(ret, "<td>]</td>")
	end
	
	table.insert(ret, "\n</tr>\n<tr>\n<th>Ancestors</th>\n")
	
	if #lang:getAncestors() > 1 then
		local ancestors = {}
		
		for _, anc in ipairs(lang:getAncestors()) do
			table.insert(ancestors, "<li>]</li>")
		end
		
		table.insert(ret, "<td><ul>\n" .. table.concat(ancestors, "\n") .. "</ul></td>\n")
	elseif #lang:getAncestorChain() > 0 then
		table.insert(ret, "<td><ul>\n")
		
		local chain = {}
		
		for _, anc in ipairs(lang:getAncestorChain()) do
			table.insert(chain, "<li>]</li>")
		end
		
		table.insert(ret, table.concat(chain, "\n<ul>\n"))
		
		for _, _ in ipairs(chain) do
			table.insert(ret, "</ul>")
		end
		
		table.insert(ret, "</td>\n")
	else
		table.insert(ret, "<td>unknown</td>\n")
	end
	
	table.insert(ret, "</tr>\n")
	
	if #lang:getScripts() > 0 then
		local scripts = {}
		
		for _, sc in ipairs(lang:getScripts()) do
			local text = ""
			if sc:getCode() ~= "Hira" then
				text = text .. "<li>]"
			end
			
			if sc:getCode() == "Jpan" then
				local m_scripts = require("Module:scripts")
				local Hani = m_scripts.getByCode("Hani")
				local Hira = m_scripts.getByCode("Hira")
				local Kana = m_scripts.getByCode("Kana")
				text = text .. "\n<ul>\n" ..
					"<li>]</li>\n" ..
					"<li>]</li>\n" ..
					"<li>]</li>\n" ..
					"</ul>\n"
			elseif sc:getCode() == "Kore" then
				local m_scripts = require("Module:scripts")
				local Hang = m_scripts.getByCode("Hang")
				local Hani = m_scripts.getByCode("Hani")
				text = text .. "\n<ul>\n" ..
					"<li>]</li>\n" ..
					"<li>]</li>\n" ..
					"</ul>\n"
			end
			
			text = text .. "</li>"
			
			table.insert(scripts, text)
		end
		
		table.insert(ret, "<tr>\n<th>]</th>\n<td><ul>\n" .. table.concat(scripts, "\n") .. "</ul></td>\n</tr>\n")
	else
		table.insert(ret, "<tr>\n<th>]</th>\n<td>not specified</td>\n</tr>\n")
	end
	
	table.insert(ret, "</table>")
	
	return table.concat(ret)
end

function export.country_categories(frame)
	local categories = {}
	
	for i, country in ipairs(frame:getParent().args) do
		if i > 1 then
			table.insert(categories, "]")
		end
	end
	
	if #categories > 0 then
		return table.concat(categories)
	else
		return "]"
	end
end


-- Category object

local Category = {}
Category.__index = Category


function Category.new(info)
	for key, val in pairs(info) do
		if not (key == "code" or key == "entryname" or key == "setsister" or key == "setwiki" or key == "setwikt") then
			error("The parameter \"" .. key .. "\" was not recognized.")
		end
	end
	
	local self = setmetatable({}, Category)
	self._info = info
	
	if not self._info.code then
		error("No language code was specified.")
	else
		self._lang = require("Module:languages").getByCode(self._info.code) or error("The language code \"" .. self._info.code .. "\" is not valid.")
	end
	
	return self
end

export.new = Category.new


function Category:getInfo()
	return self._info
end


function Category:getBreadcrumbName()
	return self._lang:getCanonicalName()
end


function Category:getDataModule()
	return "Module:category tree/langcatboiler"
end


function Category:canBeEmpty()
	return true
end


function Category:isHidden()
	return false
end


function Category:getCategoryName()
	return mw.getContentLanguage():ucfirst(self._lang:getCategoryName())
end


function Category:getDescription()
	if self._lang:getCode() == "und" then
		return
			"This is the main category of the '''" .. self._lang:getCategoryName() .. "''', represented in Wiktionary by the ] '''" .. self._lang:getCode() .. "'''. " ..
			"This language contains terms in historical writing, whose meaning has not yet been determined by scholars."
	end
	
	local ret = linkbox(self._lang, self._info.setwiki, self._info.setsister, self._info.entryname)
	
	ret = ret .. "This is the main category of the '''" .. self._lang:getCategoryName() .. "'''.\n\nInformation about " .. self._lang:getCanonicalName() .. ":\n\n" .. infobox(self._lang)
	
	if self._lang:getType() == "reconstructed" then
		ret = ret .. "\n\n" ..
			self._lang:getCanonicalName() .. " is a reconstructed language. Its words and roots are not directly attested in any written works, but have been reconstructed through the ''comparative method'', " ..
			"which finds regular similarities between languages that cannot be explained by coincidence or word-borrowing, and extrapolates ancient forms from these similarities.\n\n" ..
			"According to our ], terms in " .. self._lang:getCanonicalName() ..
			" should '''not''' be present in entries in the main namespace, but may be added to the Reconstruction: namespace."
	elseif self._lang:getType() == "appendix-constructed" then
		ret = ret .. "\n\n" ..
			self._lang:getCanonicalName() .. " is a constructed language that is only in sporadic use. " ..
			"According to our ], terms in " .. self._lang:getCanonicalName() ..
			" should '''not''' be present in entries in the main namespace, but may be added to the Appendix: namespace. " ..
			"All terms in this language may be available at ]."
	end
	
	local about = mw.title.new("Wiktionary:About " .. self._lang:getCanonicalName())
	
	if about.exists then
		ret = ret .. "\n\n" ..
			"Please see ''']''' for information and special considerations for creating " .. self._lang:getCategoryName() .. " entries."
	end
	
	return ret
end


function Category:getParents()
	local ret = {{name = "Category:All languages", sort = self._lang:getCanonicalName()}}
	
	local fam = self._lang:getFamily()
	
	if not fam then
		table.insert(ret, {name = "Category:Unclassified languages", sort = self._lang:getCanonicalName()})
	elseif fam:getCode() == "qfa-iso" then
		table.insert(ret, {name = "Category:Language isolates", sort = self._lang:getCanonicalName()})
	elseif fam:getCode() == "qfa-mix" then
		table.insert(ret, {name = "Category:Mixed languages", sort = self._lang:getCanonicalName()})
	elseif fam:getCode() == "sgn" then
		table.insert(ret, {name = "Category:All sign languages", sort = self._lang:getCanonicalName()})
	elseif fam:getCode() == "crp" then
		table.insert(ret, {name = "Category:Creole or pidgin languages", sort = self._lang:getCanonicalName()})
		
		for _, anc in ipairs(self._lang:getAncestors()) do
			table.insert(ret, {name = "Category:" .. anc:getCanonicalName() .. "-based creole or pidgin languages", sort = self._lang:getCanonicalName()})
		end
	elseif fam:getCode() == "art" then
		if self._lang:getType() == "appendix-constructed" then
			table.insert(ret, {name = "Category:Appendix-only constructed languages", sort = self._lang:getCanonicalName()})
		else
			table.insert(ret, {name = "Category:Constructed languages", sort = self._lang:getCanonicalName()})
		end
		
		for _, anc in ipairs(self._lang:getAncestors()) do
			table.insert(ret, {name = "Category:" .. anc:getCanonicalName() .. "-based constructed languages", sort = self._lang:getCanonicalName()})
		end
	else
		table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(fam:getCategoryName()), sort = self._lang:getCanonicalName()})
		
		if self._lang:getType() == "reconstructed" then
			table.insert(ret, {name = "Category:Reconstructed languages", sort = (mw.ustring.gsub(self._lang:getCanonicalName(), "^Proto%-", ""))})
		end
	end
	
	for _, sc in ipairs(self._lang:getScripts()) do
		table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(sc:getCategoryName() .. " languages"), sort = self._lang:getCanonicalName()})
		
		if sc:getCode() == "Jpan" then
			table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hani"):getCategoryName() .. " languages"), sort = self._lang:getCanonicalName()})
			table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hira"):getCategoryName() .. " languages"), sort = self._lang:getCanonicalName()})
			table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Kana"):getCategoryName() .. " languages"), sort = self._lang:getCanonicalName()})
		elseif sc:getCode() == "Kore" then
			table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hang"):getCategoryName() .. " languages"), sort = self._lang:getCanonicalName()})
			table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hani"):getCategoryName() .. " languages"), sort = self._lang:getCanonicalName()})
		end
	end
	
	return ret
end


function Category:getChildren()
	local ret = {}
	
	local m_poscatboiler = require("Module:category tree/poscatboiler")
	
	for _, label in ipairs({"appendices", "entry maintenance", "lemmas", "names", "phrases", "rhymes", "symbols", "templates", "terms by etymology", "terms by usage", "transliterations"}) do
		local child = m_poscatboiler.new({code = self._lang:getCode(), label = label})
		local parents = child:getParents()
		
		if parents then
			-- Find the current category among the child's parents, to find its sort key
			for _, parent in ipairs(parents) do
				if type(parent.name) == "string" and parent.name == "Category:" .. self:getCategoryName() then
					table.insert(ret, {name = child, sort = parent.sort})
					break
				end
			end
		end
	end
	
	local m_derivcatboiler = require("Module:category tree/derivcatboiler")
	local child = m_derivcatboiler.new({code = nil, label = self._lang:getCode()})
	local sortkey = child._info.label
	local parents = child:getParents()
	
	if parents then
		-- Find the current category among the child's parents, to find its sort key
		for _, parent in ipairs(parents) do
			if type(parent.name) == "string" and parent.name == "Category:" .. self:getCategoryName() then
				sortkey = parent.sort
				break
			end
		end
	end
	
	table.insert(ret, {name = child, sort = sortkey})
	
	local m_topic_cat = require("Module:category tree/topic cat")
	local child = m_topic_cat.new({code = self._lang:getCode(), label = "all topics"})
	local sortkey = child._info.label
	local parents = child:getParents()
	
	if parents then
		-- Find the current category among the child's parents, to find its sort key
		for _, parent in ipairs(parents) do
			if type(parent.name) == "string" and parent.name == "Category:" .. self:getCategoryName() then
				sortkey = parent.sort
				break
			end
		end
	end
	
	table.insert(ret, {name = child, sort = sortkey})
	
	-- FIXME: This is hacky, but it works as a stopgap measure.
	-- We should fix this when these categories get their own category tree modules.
	table.insert(ret, {name = {
		_lang = self._lang,
		getCategoryName = function(self) return "Regional " .. self._lang:getCanonicalName() end,
		getDescription = function(self) return self._lang:getCanonicalName() .. " terms used in specific regions or dialects." end,
		}, sort = "regional"})
	
	table.insert(ret, {name = {
		_lang = self._lang,
		getCategoryName = function(self) return "Requests (" .. self._lang:getCanonicalName() .. ")" end,
		getDescription = function(self) return self._lang:getCanonicalName() .. " entries that need attention of experienced editors." end,
		}, sort = "requests"})
	
	table.insert(ret, {name = {
		_lang = self._lang,
		getCategoryName = function(self) return "User " .. self._lang:getCode() end,
		getDescription = function(self) return "Wiktionary users categorized by fluency levels in " .. self._lang:getCanonicalName() .. "." end,
		}, sort = "user"})
	
	return ret
end


function Category:getUmbrella()
	return nil
end


return export