Modul:category tree/derivcatboiler
Erscheinungsbild
local export = {}
-- Category object
local Category = {}
Category.__index = Category
function Category.new(info)
local self = setmetatable({}, Category)
assert(type(info) == "table", "Den \"info\"-parameter mot een tabel waen.")
self._info = {}
for key, val in pairs(info) do
if key == "code" then
self._info.code = val
self._lang = require("Module:languages").getByCode(val) or error("De spraokkode \"" .. val .. "\" is neet geldig.")
elseif key == "label" then
self._info.label = val
else
error("Den parameter \"" .. key .. "\" is neet bekend.")
end
end
if not self._info.label then
error("Label is neet op-egovven.")
end
-- Check if the label exists
if self._info.label ~= "ROOT" then
self._source =
require("Module:families").getByCode(self._info.label) or
require("Module:etymology language").getByCode(self._info.label) or
require("Module:languages").getByCode(self._info.label) or
error("\"" .. self._info.label .. "\" is gin geldige spraok-, familie- of etymologyspraok-kode.")
end
return self
end
export.new = Category.new
function Category:getBreadcrumbName()
if not self._source then
return "Begrepen ut annere Spraken"
else
local ret = nil
if self._source:getType() == "family" then
ret = self._source:getCategoryName()
else
ret = self._source:getCanonicalName()
end
return (not self._lang and "Begrepen ut " or "") .. ret
end
end
function Category:getDataModule()
return "Module:category tree/derivcatboiler"
end
function Category:canBeEmpty()
return false
end
function Category:getCategoryName()
local ret = nil
if not self._source then
ret = "annere Spraken"
else
if self._source:getType() == "family" then
ret = "de " .. self._source:getCategoryName()
else
ret = "dat " .. self._source:getCanonicalName()
end
end
if self._lang then
return mw.getContentLanguage():ucfirst(self._lang:getCanonicalName() .. " Begrepen ut " .. ret)
else
return "Begrepen ut " .. ret
end
end
function Category:getDescription()
local ret = nil
if not self._lang then
if not self._source then
return "Kategorien met weurde in verscheidene spraoken oet aandere spraoken."
elseif self._source:getType() == "family" then
return "Kategorien met weurde in verscheidene spraoken oet " .. self._source:getCategoryName() .. "."
else
return "Kategorien met weurde in verscheiden spraoken oet " .. self._source:getCanonicalName() .. " ."
end
else
if not self._source then
return "Weurde in t " .. self._lang:getCanonicalName() .. " ofkumstig oet aandere spraoken."
elseif self._source:getType() == "family" then
return
"Weurde in t " .. self._lang:getCanonicalName() .. " ofkumstig oet " ..
"[[:Category:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()) .. "|" .. self._source:getCategoryName() .. "]].\n\n" ..
"This category should, ideally, contain only other categories. Entries can be categorized here, too, when the proper subcategory is unclear. " ..
"If you know the exact language from which an entry categorized here is derived, please edit its respective entry."
elseif self._source:getType() == "etymology language" then
return "Terms in " .. self._lang:getCanonicalName() .. " that originate from " .. self._source:getCanonicalName() .. "."
else
return "Terms in " .. self._lang:getCanonicalName() .. " that originate from the [[:Category:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()) .. "|" .. self._source:getCategoryName() .. "]]."
end
end
end
function Category:getParents()
if self._lang then
local parent = {}
if not self._source then
return {{name = "Kategorie:" .. self._lang:getCanonicalName() .. " Etymologie", sort = "terms derived from other languages"}}
else
local pinfo = mw.clone(self._info)
local sortkey = nil
if self._source:getType() == "family" then
if self._source:getFamily():getCode() == "qfa-iso" or self._source:getFamily():getCode() == "qfa-not" or self._source:getFamily():getCode() == "qfa-und" then
pinfo.label = "ROOT"
else
pinfo.label = self._source:getFamily():getCode()
end
sortkey = self._source:getCategoryName()
elseif self._source:getType() == "etymology language" then
if self._source:getParentCode() == "qfa-iso" or self._source:getParentCode() == "qfa-not" or self._source:getParentCode() == "qfa-und" then
pinfo.label = "ROOT"
elseif self._source:getParentCode() == self._lang:getCode() then
pinfo.label = self._lang:getFamily():getCode()
else
pinfo.label = self._source:getParentCode()
end
sortkey = self._source:getCanonicalName()
else
if self._source:getFamily():getCode() == "qfa-iso" or self._source:getFamily():getCode() == "qfa-not" or self._source:getFamily():getCode() == "qfa-und" then
pinfo.label = "ROOT"
else
pinfo.label = self._source:getFamily():getCode()
end
sortkey = self._source:getCanonicalName()
end
return {{name = Category.new(pinfo), sort = sortkey}}
end
else
if not self._source then
return {{name = "Kategorie:Begrepen bi Etymologie-Ünnerkategorien bi Spraak", sort = "terms derived from other languages"}}
else
return {{name = "Kategorie:" .. mw.getContentLanguage():ucfirst(self._source:getCategoryName()), sort = "terms derived from"}}
end
end
end
function Category:getChildren()
return nil
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
function Category:getBild()
return nil
end
return export