Модул:category tree/PIE root cat
Script error: The function "main" does not exist.
local export = {}
-- Category object
local Category = {}
Category.__index = Category
function Category.new_main(frame)
local pagename = mw.title.getCurrentTitle().text
local langName, root = mw.ustring.match(pagename, "^(.-) ?[пП]ојмови изведени из корена PIE (.+)$")
local lang, id
if langName then
if langName ~= "" then
lang = require("Модул:languages").getByCanonicalName(langName) or
error('Име језика "' .. langName .. '" у наслову странице није важећи.')
end
if mw.ustring.find(root, " %(") then
root, id = mw.ustring.match(root, "^(.+) %((.*)%)$")
end
if id == "" then
id = nil
end
end
return Category.new{
catLang = lang,
label = root,
id = id
}
end
function Category.new(info)
local validKeys = {
catLang = true,
code = true,
label = true,
id = true,
}
for key, val in pairs(info) do
if not validKeys[key] then
error("Параметар \"" .. key .. "\" није препознат.")
end
end
local self = setmetatable({}, Category)
self._info = info
self._info.lang = require("Модул:languages").getByCode("ine-pro")
if self._info.code or self._info.catLang then
self._lang = self._info.catLang or require("Модул:languages").getByCode(self._info.code) or error("The language code \"" .. self._info.code .. "\" is not valid.")
if not self._info.code then
self._info.code = self._lang:getCode()
end
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._info.label then
local root = require("Модул:script utilities").tag_text(
self._info.label,
self._info.lang,
nil,
"term"
)
if self._info.id then
root = root .. " (" .. self._info.id .. ")"
end
return root
else
return "Појмови изведени од Пра-Индо-Европски корена"
end
end
function Category:getDataModule()
return "Модул:category tree/PIE root cat"
end
function Category:canBeEmpty()
if self._lang then
return false
else
return true
end
end
function Category:isHidden()
return false
end
function Category:getCategoryName()
if self._info.label then
local shared = " изведени из корена PIE " ..
self._info.label
if self._info.id then
shared = shared .. " (" .. self._info.id .. ")"
end
if self._lang then
return self._lang:getCanonicalName() .. " појмови" .. shared
else
return "Појмови" .. shared
end
else
return "Појмови изведени од Пра-Индо-Европски корена"
end
end
function Category:getDescription()
if self._info.label then
local shared = " that originate ultimately from the [[w:Proto-Indo-European root|Пра-Индо-Европски корен]] " ..
require("Модул:links").full_link(
{
term = self._info.label,
lang = self._info.lang,
id = self._info.id
},
"term"
)
mw.getCurrentFrame():callParserFunction(
"DISPLAYTITLE",
require("Модул:string").plain_gsub(
"Категорија:" .. self:getCategoryName(),
self._info.label,
require("Модул:script utilities").tag_text(
self._info.label,
self._info.lang,
nil,
"term"
)
)
)
if self._lang then
return self._lang:getCanonicalName() .. " појмови" .. shared
else
return "Појмови" .. shared
end
else
return "Категорије за појмове произведене од посебног [[w:Proto-Indo-European root|Пра-Индо-Европски корени]]."
end
end
function Category:getParents()
local parents = {}
if self._lang then -- langname изрази изведени из корена ПИЕ
table.insert(
parents,
{
name = require("Модул:category tree/poscatboiler")
.new {
code = self._info.code,
label = "појмови по PIE корену",
},
-- PIE sortkey
sort = self._info.lang:makeSortKey(self._info.label)
}
)
table.insert(
parents,
{
name = require("Модул:category tree/PIE root cat")
.new {
code = nil,
label = self._info.label,
id = self._info.id
},
sort = self._lang:getCanonicalName()
}
)
else -- terms derived from PIE root
if self._info.label then
table.insert(
parents,
{
name = Category.new {
code = nil,
label = nil,
id = nil
},
-- PIE sortkey
sort = self._info.lang:makeSortKey(self._info.label)
}
)
else
table.insert(
parents,
{
name = require("Модул:category tree/poscatboiler")
.new {
code = "ine-pro",
label = "корени",
},
sort = " "
}
)
table.insert(
parents,
{
name = require("Модул:category tree/derivcatboiler")
.new {
label = "ine-pro",
},
sort = " корени"
}
)
end
end
if self._info.id then
table.insert(
parents,
{
name = Category.new {
catLang = self._lang,
label = self._info.label,
id = nil
},
sort = " " .. self._info.id
}
)
end
return parents
end
function Category:getChildren()
return nil
end
function Category:getUmbrella()
return nil
end
return export