Модул:category tree/affix cat
Script error: The function "main" does not exist.
local m_links = require("Модул:links")
local m_compound = require("Модул:compound")
local export = {}
-- Category object
local Category = {}
Category.__index = Category
function Category.new_main(frame)
local params = {
[1] = {required = true},
[2] = {required = true},
[3] = {},
["id"] = {},
["pos"] = {},
["sc"] = {},
["sort"] = {},
["tr"] = {},
}
args = require("Модул:parameters").process(frame:getParent().args, params)
local info = {code = args[1], term = args[2], alt = args[3], id = args["id"], pos = args["pos"], sc = args["sc"], sort = args["sort"], tr = args["tr"], affixtype = frame.args["affixtype"]}
return Category.new(info)
end
function Category.new(info)
local self = setmetatable({}, Category)
for key, val in pairs(info) do
if not (key == "affixtype" or key == "alt" or key == "code" or key == "id" or key == "pos" or key == "sc" or key == "sort" or key == "term" or key == "tr") then
error("The parameter \"" .. key .. "\" was not recognized.")
end
end
self._info = info
-- Add default POS, or make POS plural.
self._pos = self._info.pos or "речи"
if not self._pos:find("ч$") then
if self._pos:find("са$") then
self._pos = self._pos .. "и"
else
self._pos = self._pos .. "са"
end
end
if not self._info.code then
error("No language code was specified.")
end
if not self._info.term then
error("No term was specified.")
end
self._lang = require("Модул:languages").getByCode(self._info.code) or error("Језички код \"" .. self._info.code .. "\" није добар.")
self._sc = (self._info.sc and (require("Модул:scripts").getByCode(val) or error("Код писма \"" .. val .. "\" није добар.")) or nil)
self._term = m_compound.make_affix(self._info.term, self._lang, self._sc, self._info.affixtype)
self._alt = m_compound.make_affix(self._info.alt, self._lang, self._sc, self._info.affixtype)
self._tr = m_compound.make_affix(self._info.tr, self._lang, require("Модул:scripts").getByCode("Latn"), self._info.affixtype)
-- Convert term/alt into affixes if needed
local desc = {
["са префиксом"] = "beginning with the prefix",
["affix"] = "завршава са суфиксом",
["circumfix"] = "bookended with the circumfix",
["уметнуте са"] = "спојена са инфиксом",
["interfix"] = "joined with the interfix",
["transfix"] = "patterned with the transfix",
}
if self._info.affixtype then
self._desc = desc[self._info.affixtype] or error(self._info.affixtype .. " није препознат тип афикса.")
else
error("Молим provide a тип of affix in the affixtype параметар.")
end
return self
end
export.new = Category.new
export.new_main = Category.new_main
function Category:getInfo()
return self._info
end
function Category:getBreadcrumbName()
if self._pos and self._pos == "речи" then
local affix = require("Модул:script utilities").tag_text(
self._alt or self._term,
self._lang,
self._sc,
"term"
)
if self._info.id then
return affix .. " (" .. self._info.id .. ")"
else
return affix
end
else
return self._pos
end
end
function Category:getDataModule()
return "Модул:category tree/affix cat"
end
function Category:canBeEmpty()
return false
end
function Category:isHidden()
return false
end
function Category:getCategoryName()
return self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._info.affixtype .. " са " .. self._lang:makeEntryName(self._term) .. (self._info.id and " (" .. self._info.id .. ")" or "")
end
function Category:getDescription()
local description =
self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._desc .. " " ..
m_links.full_link({lang = self._lang, term = self._term, alt = self._alt, sc = self._sc, id = self._info.id, tr = self._tr}, "term") ..
"."
mw.getCurrentFrame():callParserFunction(
"DISPLAYTITLE",
"Категорија:" .. self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._info.affixtype .. 'са ' .. require("Модул:script utilities").tag_text(self._lang:makeEntryName(self._term), self._lang, self._script, "term") .. (self._info.id and " (" .. self._info.id .. ")" or "")
)
return description
end
function Category:getParents()
local parents = {}
local parent
if self._info.id then
if self._pos and self._pos == "речи" then
parent = {}
parent.name = export.new({
code = self._info.code,
term = self._info.term,
affixtype = self._info.affixtype
})
parent.sort = self._info.id
table.insert(parents, parent)
else
parent = {}
parent.name = export.new({
code = self._info.code,
term = self._info.term,
affixtype = self._info.affixtype,
id = self._info.id
})
parent.sort = self._info.id .. ", " .. self._info.pos
table.insert(parents, parent)
parent = {}
parent.name = export.new({
code = self._info.code,
term = self._info.term,
affixtype = self._info.affixtype,
pos = self._info.pos
})
parent.sort = self._info.id
table.insert(parents, parent)
end
else
if self._pos and self._pos ~= "речи" then
parent = {}
parent.name = export.new({
code = self._info.code,
term = self._info.term,
affixtype = self._info.affixtype
})
parent.sort = self._info.pos
table.insert(parents, parent)
end
end
parent = {}
parent.name = require("Модул:category tree/poscatboiler").new({code = self._info.code, label = "речи са" .. self._info.affixtype})
parent.sort = self._lang:makeSortKey(self._info.sort or self._term)
table.insert(parents, parent)
return parents
end
function Category:getChildren()
return nil
end
function Category:getUmbrella()
return nil
end
return export