Модул:category tree/translitcatboiler
This module implements {{translitcatboiler}}
. The documentation here describes how the module works, and how to add, modify or remove information from the category tree. For information on how to use the template itself, see its documentation.
This module does not use a data module with recognised labels. Instead, the labels are taken directly from Module:languages. Thus, any valid language code is a valid label. For the top-level category, the label ROOT
is used.
Горња документација је укључена са странице Модул:category tree/translitcatboiler/док. (уреди | историја) Уредници могу да експериментишу на подстраницама песак (направи | дуплирај) и тест (направи) овог модула. Подстранице овог модула. |
local export = {}
-- Category object
local Category = {}
Category.__index = Category
function Category.new(info)
local self = setmetatable({}, Category)
assert(type(info) == "table", "The \"info\" parameter must be a table.")
self._info = {}
for key, val in pairs(info) do
if key == "code" then
self._info.code = val
self._lang = require("Модул:languages").getByCode(val) or error("The language code \"" .. val .. "\" is not valid.")
elseif key == "label" then
self._info.label = val
else
error("The parameter \"" .. key .. "\" was not recognized.")
end
end
if not self._info.label then
error("No label was specified.")
end
-- Check if the label exists
if self._info.label ~= "ROOT" then
self._source = require("Модул:languages").getByCode(self._info.label) or error("The language code \"" .. self._info.label .. "\" is not valid.")
end
return self
end
export.new = Category.new
function Category:getInfo()
return self._info
end
function Category:getBreadcrumbName()
if self._source then
if self._lang then
return self._source:getCanonicalName()
else
return "Термини транслитерирани од " .. self._source:getCanonicalName()
end
else
if self._lang then
return "Транслитерирани термини"
else
return "Термини транслитерирани од других језика"
end
end
end
function Category:getDataModule()
return "Module:category tree/translitcatboiler"
end
function Category:getCategoryName()
local ret = nil
if self._source then
ret = "транслитерације од " .. self._source:getCanonicalName() .. " израза"
else
ret = "термини транслитерирани од других језика"
end
if self._lang then
return mw.getContentLanguage():ucfirst(self._lang:getCanonicalName() .. " " .. ret)
else
return mw.getContentLanguage():ucfirst(ret)
end
end
function Category:getDescription()
local ret
if self._lang then
if self._source then
ret = "the [[:Категорија:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()) .. "|" .. self._source:getCategoryName() .. "]]"
else
ret = "други језици"
end
return "Термини у " .. self._lang:getCanonicalName() .. " треба да буду транслитерирани од " .. ret .. "."
else
if self._source then
ret = "транслитерација од " .. self._source:getCanonicalName() .. " термини"
else
ret = "термини транслитерирани од других језика"
end
return "Категорије са " .. ret .. " у разним специфичним језицима."
end
end
function Category:getParents()
if self._lang then
if self._source then
local pinfo = mw.clone(self._info)
pinfo.label = "ROOT"
return {
{name = Category.new(pinfo), sort = self._source:getCanonicalName()},
{name = require("Модул:category tree/borrowed cat").new({code = self._info.code, label = self._source:getCode()}), sort = " "},
}
else
return {
{name = require("Модул:category tree/poscatboiler").new({code = self._info.code, label = "позајмљени изрази"}), sort = " "},
}
end
else
if self._source then
return {{name = require("Модул:category tree/borrowed cat").new({label = self._source:getCode()}), sort = " "}}
else
return {{name = "Категорија:Појмови по етимологији подкатегорије по језику", sort = "појмови транслитерирани од других језика"}}
end
end
end
function Category:getChildren()
return nil
end
function Category:canBeEmpty()
return false
end
function Category:isHidden()
return false
end
function Category:getUmbrella()
if not self._lang then
return nil
end
local uinfo = mw.clone(self._info)
uinfo.code = nil
return Category.new(uinfo)
end
return export