Modul:category tree/tone cat
A modult a Modul:category tree/tone cat/doc lapon tudod dokumentálni
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("Module:parameters").process(frame:getParent().args, params)
return Category.new({lang = args[1], pos = args[2], tone = args[3]})
end
function Category.new(info)
for key, val in pairs(info) do
if not (key == "lang" or key == "pos" or key == "tone") then
error("The parameter \"" .. key .. "\" was not recognized. "
.."Recognized parameters are \"lang\", \"pos\", and \"tone\".")
end
end
if not info.lang then
error("No current language code was specified.")
end
if not info.pos then
error("No part of speech was specified.")
end
if not info.tone then
error("No tone 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("Module:languages").getByCode(info.lang, true)
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._info.tone
end
function Category:getDataModule()
return "Module:category tree/tone cat"
end
function Category:canBeEmpty()
return false
end
function Category:isHidden()
return false
end
function Category:getCategoryName()
return self._lang:getCanonicalName() .. " " .. self._info.pos .. " with tone " .. self._info.tone
end
local function linkLanguage(lang)
return "[[:Category:" .. mw.getContentLanguage():ucfirst(lang:getCategoryName()) .. "|" .. lang:getCanonicalName() .. "]]"
end
function Category:getDescription()
return linkLanguage(self._lang) .. " " .. self._info.pos .. " with tone " .. self._info.tone .. "."
end
function Category:getParents()
local categories = {}
table.insert(categories,
{name = require("Module:category tree/poscatboiler").new{code = self._info.lang, label = self._info.pos .. " by tone"},
sort = "" .. self._info.tone:len() .. self._info.tone
})
return categories
end
function Category:getChildren()
return nil
end
function Category:getUmbrella()
return nil
end
return export
-- For Vim, so we get 4-space tabs
-- vim: set ts=4 sw=4 noet: