Модул:category tree/nameboiler
Script error: The function "main" does not exist.
local export = {}
-- Category object
local Category = {}
Category.__index = Category
function Category.new_main(frame)
local params = {
[1] = {required = true},
[2] = {required = true},
[3] = {required = true},
}
args = require("Модул:parameters").process(frame:getParent().args, params)
return Category.new({nametype = args[1], lang = args[2], source = args[3]})
end
function Category.new(info)
for key, val in pairs(info) do
if not (key == "nametype" or key == "lang" or key == "source") then
error("Параметар \"" .. key .. "\" није препознат. "
.."Препознати параметри су \"nametype\", \"lang\", и \"source\".")
end
end
if not info.nametype then
error("No name type was specified.")
end
if not info.lang then
error("No current language code was specified.")
end
if not info.source then
error("No source language code was specified.")
end
local self = setmetatable({}, Category)
self._info = info
self._lang = type(info.lang) == "table" and info.lang.getCode and info.lang
or require("Модул:languages").getByCode(info.lang) or error("The language code \"" .. info.lang .. "\" is not valid.")
self._source = type(info.source) == "table" and info.source.getCode and info.source
or require("Модул:languages").getByCode(info.source) or error("\"" .. info.source .. "\" is not a valid language or etymology-only language code.")
return self
end
export.new = Category.new
export.new_main = Category.new_main
function Category:getInfo()
return self._info
end
function Category:getBreadcrumbName()
return "од " .. self._source:getCanonicalName()
end
function Category:getDataModule()
return "Модул:category tree/nameboiler"
end
function Category:canBeEmpty()
return false
end
function Category:isHidden()
return false
end
function Category:getCategoryName()
return mw.getContentLanguage():ucfirst(self._lang:getCanonicalName() .. " " .. self._info.nametype .. " " .. self._source:getCanonicalName())
end
function Category:getDescription()
return self._lang:getCanonicalName() .. " " .. self._info.nametype .. " од [[:Категорија:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()) .. "|" .. self._source:getCategoryName() .. "]] origin."
end
function Category:getParents()
local categories = {}
local nametype = self._info.nametype
table.insert(categories,
{name = require("Модул:category tree/poscatboiler").new{code = self._info.lang, label = nametype},
sort = self._source:getCanonicalName()})
table.insert(categories,
{name = require("Модул:category tree/derivcatboiler").new{code = self._info.lang, label = self._source:getCode()},
sort = " "})
if nametype:find("^мушка дата имена$") or nametype:find("^женска дата имена$") then
local gender, label = nametype:match("^(мушко) (.+)$") or nametype:match("^(женско) (.+)$")
table.insert(categories,
{name = Category.new{lang = self._info.lang, nametype = label, source = self._source},
sort = gender
})
end
return categories
end
function Category:getChildren()
return nil
end
function Category:getUmbrella()
return nil
end
return export