Module:User:Balyozxane: difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
m indent |
added script tagging to affix in title |
||
Line 120: | Line 120: | ||
m_links.full_link({lang = self._lang, term = self._term, alt = self._alt, sc = self._sc, id = self._info.id, tr = self._tr}, "term") .. |
m_links.full_link({lang = self._lang, term = self._term, alt = self._alt, sc = self._sc, id = self._info.id, tr = self._tr}, "term") .. |
||
"." |
"." |
||
mw.getCurrentFrame():callParserFunction( |
|||
"DISPLAYTITLE", |
|||
"Category:" .. self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._info.affixtype .. 'ed with ' .. require("Module:script utilities").tag_text(self._lang:makeEntryName(self._term), self._lang, self._script) .. (self._info.id and " (" .. self._info.id .. ")" or "") |
|||
) |
|||
return description |
return description |
Revision as of 04:59, 9 July 2017
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: subpage list • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Balyozxane, for their own experimentation. Items in this module may be added and removed at Balyozxane's discretion; do not rely on this module's stability.
local m_links = require("Module:links")
local m_compound = require("Module:compound")
local export = {}
-- Category object
local Category = {}
Category.__index = Category
function Category.new_main(frame)
local params = {
[1] = {required = true},
[2] = {required = true},
[3] = {},
["id"] = {},
["pos"] = {},
["sc"] = {},
["sort"] = {},
["tr"] = {},
}
args = require("Module:parameters").process(frame:getParent().args, params)
local info = {code = args[1], term = args[2], alt = args[3], id = args["id"], pos = args["pos"], sc = args["sc"], sort = args["sort"], tr = args["tr"], affixtype = frame.args["affixtype"]}
return Category.new(info)
end
function Category.new(info)
local self = setmetatable({}, Category)
for key, val in pairs(info) do
if not (key == "affixtype" or key == "alt" or key == "code" or key == "id" or key == "pos" or key == "sc" or key == "sort" or key == "term" or key == "tr") then
error("The parameter \"" .. key .. "\" was not recognized.")
end
end
self._info = info
-- Make pos plural
self._pos = self._info.pos or "words"
if not self._pos:find("s$") then
if self._pos:find("x$") then
self._pos = self._pos .. "es"
else
self._pos = self._pos .. "s"
end
end
if not self._info.code then
error("No language code was specified.")
end
if not self._info.term then
error("No term was specified.")
end
self._lang = require("Module:languages").getByCode(self._info.code) or error("The language code \"" .. self._info.code .. "\" is not valid.")
self._sc = (self._info.sc and (require("Module:scripts").getByCode(val) or error("The script code \"" .. val .. "\" is not valid.")) or nil)
self._term = m_compound.make_affix(self._info.term, self._lang, self._sc, self._info.affixtype)
self._alt = m_compound.make_affix(self._info.alt, self._lang, self._sc, self._info.affixtype)
self._tr = m_compound.make_affix(self._info.tr, self._lang, require("Module:scripts").getByCode("Latn"), self._info.affixtype)
-- Convert term/alt into affixes if needed
local desc = {
["prefix"] = "beginning with the prefix",
["suffix"] = "ending with the suffix",
["circumfix"] = "bookended with the circumfix",
["infix"] = "spliced with the infix",
["interfix"] = "joined with the interfix",
["transfix"] = "patterned with the transfix",
}
self._desc = desc[self._info.affixtype] or error("Invalid affixtype specified.")
return self
end
export.new = Category.new
export.new_main = Category.new_main
function Category:getInfo()
return self._info
end
function Category:getBreadcrumbName()
local link = m_links.full_link({lang = self._lang, alt = self._alt or self._term, sc = self._sc, tr = "-"}, "term")
return self._pos .. " " .. self._info.affixtype .. "ed with " .. link .. (self._info.id and " (" .. self._info.id .. ")" or "")
end
function Category:getDataModule()
return "Module:category tree/affix cat"
end
function Category:canBeEmpty()
return false
end
function Category:isHidden()
return false
end
function Category:getCategoryName()
return self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._info.affixtype .. "ed with " .. self._lang:makeEntryName(self._term) .. (self._info.id and " (" .. self._info.id .. ")" or "")
end
function Category:getDescription()
local description =
self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._desc .. " " ..
m_links.full_link({lang = self._lang, term = self._term, alt = self._alt, sc = self._sc, id = self._info.id, tr = self._tr}, "term") ..
"."
mw.getCurrentFrame():callParserFunction(
"DISPLAYTITLE",
"Category:" .. self._lang:getCanonicalName() .. " " .. self._pos .. " " .. self._info.affixtype .. 'ed with ' .. require("Module:script utilities").tag_text(self._lang:makeEntryName(self._term), self._lang, self._script) .. (self._info.id and " (" .. self._info.id .. ")" or "")
)
return description
end
function Category:getParents()
local parents = {}
local parent
parent = {}
parent.name = require("Module:category tree/poscatboiler").new({code = self._info.code, label = "words by " .. self._info.affixtype})
parent.sort = self._lang:makeSortKey(self._info.sort or self._term)
table.insert(parents, parent)
if self._info.id then
parent = {}
parent.name = export.new({code = self._info.code, term = self._info.term, affixtype = self._info.affixtype})
parent.sort = self._lang:makeSortKey(self._info.id)
table.insert(parents, parent)
end
return parents
end
function Category:getChildren()
return nil
end
function Category:getUmbrella()
return nil
end
return export