Modul:category tree/langcatboiler
Erscheinungsbild
local export = {}
local function linkbox(lang, setwiki_nds_de, setwiki_nds_nl, setwiki_frr, setsister, entryname)
local wiktionarylinks = "''Gin.''"
if #lang:getWikimediaLanguages() > 0 then
wiktionarylinks = {}
for _, wikimedialang in ipairs(lang:getWikimediaLanguages()) do
table.insert(wiktionarylinks,
(wikimedialang:getCanonicalName() ~= lang:getCanonicalName() and "(''" .. wikimedialang:getCanonicalName() .. "'') " or "") ..
"'''[[:" .. wikimedialang:getCode() .. ":|" .. wikimedialang:getCode() .. ".wiktionary.org]]'''")
end
wiktionarylinks = table.concat(wiktionarylinks, "<br/>")
end
return [=[<div style="clear: right; border: solid #aaa 1px; margin: 1 1 1 1; background: #f9f9f9; width: 270px; padding: 5px; margin: 5px; text-align: left; float: right">
<div style="text-align: center; margin-bottom: 10px; margin-top: 5px">''']=] .. lang:getCategoryName() .. [=['''</div>
{| style="font-size: 90%; background: #f9f9f9"
|-
| style="vertical-align: Middle; height: 35px" width="35px" | [[File:Wiktionary-logo.svg|35px|none|Wiktionary]]
|| '']=] .. lang:getCategoryName() .. [=[ editsie]=] .. (#lang:getWikimediaLanguages() > 1 and "s" or "") .. [=[ vun Wiktionary''
|-
| colspan="2" style="padding-left:10px" | ]=] ..
wiktionarylinks .. [=[
|-
| style="vertical-align: Middle; height: 35px" | [[File:Wikipedia-logo.png|35px|none|Wikipedia]]
|| ''Wikipedia-artikel över ]=] .. lang:getCategoryName() .. [=[''
|-
| colspan="2" style="padding-left:10px" | ]=] .. (setwiki_nds_de == "-" and "<small>(nds-de)</small> ''Keen.''" or "<small>(nds-de)</small> '''[[w:nds:" .. (setwiki_nds_de or lang:getCategoryName()) .. "|" .. (setwiki_nds_de or lang:getCategoryName()) .. "]]'''") .. [=[
|-
| colspan="2" style="padding-left:10px" | ]=] .. (setwiki_nds_nl == "-" and "<small>(nds-nl)</small> ''Keen.''" or "<small>(nds-nl)</small> '''[[w:nds-nl:" .. (setwiki_nds_nl or lang:getCategoryName()) .. "|" .. (setwiki_nds_nl or lang:getCategoryName()) .. "]]'''") .. [=[
|-
| colspan="2" style="padding-left:10px" | ]=] .. (setwiki_frr == "-" and "<small>(frr)</small> ''Keen.''" or "<small>(frr)</small> '''[[w:frr:" .. (setwiki_frr or lang:getCategoryName()) .. "|" .. (setwiki_frr or lang:getCategoryName()) .. "]]'''") .. [=[
|-
| style="vertical-align: Middle; height: 35px" | [[File:Wikimedia-logo.svg|35px|none|Wikimedia Commons]]
|| ''Links relateerd an ]=] .. lang:getCategoryName() .. [=[ op Wikimedia Commons''
|-
| colspan="2" style="padding-left:10px" | ]=] .. (setsister == "-" and "''None.''" or "'''[[commons:Category:" .. (setsister or lang:getCategoryName()) .. "|" .. (setsister or lang:getCategoryName()) .. "]]'''") .. [=[
|-
| style="vertical-align: Middle; height: 35px" | [[File:Crystal kfind.png|35px|none|Considerations]]
|| ]=] .. lang:getCategoryName() .. [=[ ovverwaegingen
|-
| colspan="2" style="padding-left:10px" | '''[[Wiktionary:Över ]=] .. lang:getCanonicalName() .. [=[]]'''
|-
| style="vertical-align: Middle; height: 35px" | [[File:Incomplete list.svg|35px|none|Index]]
|| ]=] .. lang:getCategoryName() .. [=[ index
|-
| colspan="2" style="padding-left:10px" | '''[[Index:]=] .. lang:getCanonicalName() .. [=[]]'''
|-
| style="vertical-align: Middle; height: 35px" | [[File:Open book nae 02.svg|35px|none|Entry]]
|| ]=] .. lang:getCategoryName() .. [=[ artikel
|-
| colspan="2" style="padding-left:10px" | ''']=] .. require("Module:links").full_link(entryname or lang:getCanonicalName(), nil, require("Module:languages").getByCode("en"), nil, nil, nil, {}, false) .. [=['''
|}
</div>]=]
end
function export.country_categories(frame)
local categories = {}
for i, country in ipairs(frame:getParent().args) do
if i > 1 then
table.insert(categories, "[[Kategorie:Spraken vun " .. country .. "]]")
end
end
if #categories > 0 then
return table.concat(categories)
else
return "[[Kategorie:Spraak is nicht binnen in een Landes-Kategorie]]"
end
end
-- Category object
local Category = {}
Category.__index = Category
function Category.new(info)
local self = setmetatable({}, Category)
assert(type(info) == "table", "De \"info\" parameter mot ne tabel waen.")
self._info = 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 == "entryname" then
self._info.entryname = val
elseif key == "setsister" then
self._info.setsister = val
elseif key == "setwiki_nds_de" then
self._info.setwiki_nds_de = val
elseif key == "setwiki_nds_nl" then
self._info.setwiki_nds_nl = val
elseif key == "setwiki_frr" then
self._info.setwiki_frr = val
elseif key == "setwikt" then
self._info.setwikt = val
else
error("De parameter \"" .. key .. "\" is neet bekend.")
end
end
if not self._info.code then
error("Gin spraokkode op-egovven.")
end
return self
end
export.new = Category.new
function Category:getBreadcrumbName()
return mw.getContentLanguage():ucfirst(self._lang:getCategoryName())
end
function Category:getDataModule()
return "Module:category tree/langcatboiler"
end
function Category:canBeEmpty()
return true
end
function Category:getCategoryName()
return mw.getContentLanguage():ucfirst(self._lang:getCategoryName())
end
function Category:getDescription()
if self._lang:getCode() == "und" then
return
"This is the main category of the '''" .. self._lang:getCategoryName() .. "''', represented in Wiktionary by the [[Wiktionary:Languages|code]] '''" .. self._lang:getCode() .. "'''. " ..
"This language contains terms in historical writing, whose meaning has not yet been determined by scholars."
end
local ret = linkbox(self._lang, self._info.setwiki_nds_de, self._info.setwiki_nds_nl, self._info.setwiki_frr, self._info.setsister, self._info.entryname)
ret = ret .. "Düs is de Hööftkategorie för '''" .. self._lang:getCategoryName() .. "'''.\n\nInformatschoon " .. self._lang:getCanonicalName() .. ":\n\n"
ret = ret .. "<table class=\"wikitable\">\n"
ret = ret .. "<tr>\n<th>Name</th><td>" .. self._lang:getCanonicalName() .. "</td>\n</tr>\n"
if #self._lang:getOtherNames() > 0 then
local names = {}
for _, name in ipairs(self._lang:getOtherNames()) do
table.insert(names, "<li>" .. name .. "</li>")
end
ret = ret .. "<tr>\n<th>Andere namen</th><td>" .. table.concat(names, "\n") .. "</td>\n</tr>\n"
end
ret = ret .. "<tr>\n<th>[[Wiktionary:Spraken|Spraokkode]]</th><td><code>" .. self._lang:getCode() .. "</code></td>\n</tr>\n"
ret = ret .. "<tr>\n<th>[[Wiktionary:Spraakfamilien|Spraokfamilie]]</th>\n"
local fam = self._lang:getFamily()
if fam:getCode() == "qfa-iso" then
ret = ret .. "<td>[[:Kategorie:Isoleerte Spraken|isoleerte Spraak]]</td>"
elseif fam:getCode() == "qfa-mix" then
ret = ret .. "<td>[[:Kategorie:Mischte Spraken|mischt Spraak]]</td>"
elseif fam:getCode() == "qfa-und" then
ret = ret .. "<td>een nich klassifizeerte Spraak</td>"
elseif fam:getCode() == "sgn" then
ret = ret .. "<td>een Tekenspraak, de</td>"
elseif fam:getCode() == "crp" then
ret = ret .. "<td>[[:Kategorie:Spraken - Pidgin- un Kreolen|Kreolen- oder Pidginspraak]]</td>"
elseif fam:getCode() == "art" then
ret = ret .. "<td>[[:Kategorie:Konstrueerte Spraken|konstrueerte Spraak]]</td>"
else
ret = ret .. "<td>[[:Kategorie:" .. fam:getCategoryName() .. "|" .. fam:getCanonicalName() .. "]]</td>"
end
ret = ret .. "\n</tr>\n<tr>\n<th>Öllern</th>\n"
if #self._lang:getAncestors() > 1 then
local ancestors = {}
for _, anc in ipairs(self._lang:getAncestors()) do
table.insert(ancestors, "<li>[[:Kategorie:" .. anc:getCategoryName() .. "|" .. anc:getCanonicalName() .. "]]</li>")
end
ret = ret .. "<td><ul>\n" .. table.concat(ancestors, "\n") .. "</ul></td>\n"
elseif #self._lang:getAncestorChain() > 0 then
ret = ret .. "<td><ul>\n"
local chain = {}
for _, anc in ipairs(self._lang:getAncestorChain()) do
table.insert(chain, "<li>[[:Kategorie:" .. anc:getCategoryName() .. "|" .. anc:getCanonicalName() .. "]]</li>")
end
ret = ret .. table.concat(chain, "\n<ul>\n")
for _, _ in ipairs(chain) do
ret = ret .. "</ul>"
end
ret = ret .. "</td>\n"
else
ret = ret .. "<td>neet bekend</td>\n"
end
ret = ret .. "</tr>\n"
if #self._lang:getScripts() > 0 then
local scripts = {}
for _, sc in ipairs(self._lang:getScripts()) do
local text = "<li>[[:Kategorie:" .. sc:getCategoryName() .. "|" .. sc:getCanonicalName() .. "]]"
if sc:getCode() == "Jpan" then
local m_scripts = require("Module:scripts")
local Hani = m_scripts.getByCode("Hani")
local Hira = m_scripts.getByCode("Hira")
local Kana = m_scripts.getByCode("Kana")
text = text .. "\n<ul>\n" ..
"<li>[[:Kategorie:" .. Hani:getCategoryName() .. "|" .. Hani:getCanonicalName() .. "]]</li>\n" ..
"<li>[[:Kategorie:" .. Hira:getCategoryName() .. "|" .. Hira:getCanonicalName() .. "]]</li>\n" ..
"<li>[[:Kategorie:" .. Kana:getCategoryName() .. "|" .. Kana:getCanonicalName() .. "]]</li>\n" ..
"</ul>\n"
elseif sc:getCode() == "Kore" then
local m_scripts = require("Module:scripts")
local Hang = m_scripts.getByCode("Hang")
local Hani = m_scripts.getByCode("Hani")
text = text .. "\n<ul>\n" ..
"<li>[[:Kategorie:" .. Hang:getCategoryName() .. "|" .. Hang:getCanonicalName() .. "]]</li>\n" ..
"<li>[[:Kategorie:" .. Hani:getCategoryName() .. "|" .. Hani:getCanonicalName() .. "]]</li>\n" ..
"</ul>\n"
end
text = text .. "</li>"
table.insert(scripts, text)
end
ret = ret .. "<tr>\n<th>[[Wiktionary:Schriften|Schriften]]</th>\n<td><ul>\n" .. table.concat(scripts, "\n") .. "</ul></td>\n</tr>\n"
else
ret = ret .. "<tr>\n<th>[[Wiktionary:Schriften|Schriften]]</th>\n<td>neet spesifiseerd</td>\n</tr>\n"
end
ret = ret .. "</table>"
if self._lang:getType() == "reconstructed" then
ret = ret .. "\n\n" ..
self._lang:getCanonicalName() .. " is a reconstructed language. Its words and roots are not directly attested in any written works, but have been reconstructed through the ''comparative method'', " ..
"which finds regular similarities between languages that cannot be explained by coincidence or word-borrowing, and extrapolates ancient forms from these similarities.\n\n" ..
"According to our [[Wiktionary:Criteria for inclusion|criteria for inclusion]], terms in " .. self._lang:getCanonicalName() ..
" should '''not''' be present in entries in the main namespace, but may be added to the Appendix: namespace."
elseif self._lang:getType() == "appendix-constructed" then
ret = ret .. "\n\n" ..
self._lang:getCanonicalName() .. " is a constructed language that is only in sporadic use. " ..
"According to our [[Wiktionary:Criteria for inclusion|criteria for inclusion]], terms in " .. self._lang:getCanonicalName() ..
" should '''not''' be present in entries in the main namespace, but may be added to the Appendix: namespace. " ..
"All terms in this language may be available at [[Anhang:" .. self._lang:getCanonicalName() .. "]]."
end
local about = mw.title.new("Wiktionary:Över " .. self._lang:getCanonicalName())
if about.exists then
ret = ret .. "\n\n" ..
"Kiek ok bi'j [[Wiktionary:Över " .. self._lang:getCanonicalName() .. "]] veur informatsie en ovverwaegingen bi'j t maken van " .. self._lang:getCategoryName() .. " zieden."
end
return ret
end
function Category:getParents()
local ret = {{name = "Kategorie:Spraken-Wiktionary", sort = self._lang:getCanonicalName()}}
local fam = self._lang:getFamily()
if fam:getCode() == "qfa-iso" then
table.insert(ret, {name = "Kategorie:Isoleerte Spraken", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "qfa-und" or fam:getCode() == "qfa-not" then
table.insert(ret, {name = "Kategorie:Neet klassifizeerte Spraken", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "qfa-mix" then
table.insert(ret, {name = "Kategorie:Mischte Spraken", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "sgn" then
table.insert(ret, {name = "Kategorie:All Tekenspraken", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "crp" then
table.insert(ret, {name = "Kategorie:Spraken - Pidgin- un Kreolen", sort = self._lang:getCanonicalName()})
for _, anc in ipairs(self._lang:getAncestors()) do
table.insert(ret, {name = "Kategorie:Pidgin- oder Kreoolsprake baseerd up " .. anc:getCanonicalName(), sort = self._lang:getCanonicalName()})
end
elseif fam:getCode() == "art" then
if self._lang:getType() == "appendix-constructed" then
table.insert(ret, {name = "Kategorie:Konstrueerte Spraken (Anhang)", sort = self._lang:getCanonicalName()})
else
table.insert(ret, {name = "Kategorie:Konstrueerte Spraken", sort = self._lang:getCanonicalName()})
end
for _, anc in ipairs(self._lang:getAncestors()) do
table.insert(ret, {name = "Kategorie:Konstrueerte Spraken baseerd up " .. anc:getCanonicalName(), sort = self._lang:getCanonicalName()})
end
else
table.insert(ret, {name = "Kategorie:" .. mw.getContentLanguage():ucfirst(fam:getCategoryName()), sort = self._lang:getCanonicalName()})
if self._lang:getType() == "reconstructed" then
table.insert(ret, {name = "Kategorie:Rekonstrueerte Spraken", sort = self._lang:getCanonicalName()})
end
end
for _, sc in ipairs(self._lang:getScripts()) do
table.insert(ret, {name = "Kategorie:Spraken in " .. mw.getContentLanguage():ucfirst(sc:getCategoryName() ), sort = self._lang:getCanonicalName()})
if sc:getCode() == "Jpan" then
table.insert(ret, {name = "Kategorie:Spraken in " .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hani"):getCategoryName()), sort = self._lang:getCanonicalName()})
table.insert(ret, {name = "Kategorie:Spraken in " .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hira"):getCategoryName()), sort = self._lang:getCanonicalName()})
table.insert(ret, {name = "Kategorie:Spraken in " .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Kana"):getCategoryName()), sort = self._lang:getCanonicalName()})
elseif sc:getCode() == "Kore" then
table.insert(ret, {name = "Kategorie:Spraken in " .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hang"):getCategoryName()), sort = self._lang:getCanonicalName()})
table.insert(ret, {name = "Kategorie:Spraken in " .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hani"):getCategoryName()), sort = self._lang:getCanonicalName()})
end
end
return ret
end
function Category:getChildren()
local ret = {}
local m_poscatboiler = require("Module:category tree/poscatboiler")
for _, label in ipairs({--[["appendices", "entry maintenance",--]] "Woortaarten"--[[, "names", "phrases", "rhymes", "symbols"--]],"Vörlagen", "Etymologie"--[[, "terms by usage", "transliterations"--]]}) do
local child = m_poscatboiler.new({code = self._lang:getCode(), label = label})
local sortkey = nil
local parents = child:getParents()
if parents then
-- Find the current category among the child's parents, to find its sort key
for _, parent in ipairs(parents) do
if type(parent.name) == "string" and parent.name == "Kategorie:" .. self:getCategoryName() then
sortkey = parent.sort
break
end
end
end
table.insert(ret, {name = child, sort = sortkey})
end
local m_derivcatboiler = require("Module:category tree/derivcatboiler")
local child = m_derivcatboiler.new({code = nil, label = self._lang:getCode()})
local sortkey = nil
local parents = child:getParents()
if parents then
-- Find the current category among the child's parents, to find its sort key
for _, parent in ipairs(parents) do
if type(parent.name) == "string" and parent.name == "Kategorie:" .. self:getCategoryName() then
sortkey = parent.sort
break
end
end
end
table.insert(ret, {name = child, sort = sortkey})
local m_topic_cat = require("Module:category tree/topic cat")
local child = m_topic_cat.new({code = self._lang:getCode(), label = "All Themen"})
local sortkey = nil
local parents = child:getParents()
if parents then
-- Find the current category among the child's parents, to find its sort key
for _, parent in ipairs(parents) do
if type(parent.name) == "string" and parent.name == "Kategorie:" .. self:getCategoryName() then
sortkey = parent.sort
break
end
end
end
table.insert(ret, {name = child, sort = sortkey})
-- FIXME: This is hacky, but it works as a stopgap measure.
-- We should fix this when these categories get their own category tree modules.
table.insert(ret, {name = {
_lang = self._lang,
getCategoryName = function(self) return "Regional " .. self._lang:getCanonicalName() end,
getDescription = function(self) return self._lang:getCanonicalName() .. " terms used in specific regions or dialects." end,
}, sort = "regional"})
table.insert(ret, {name = {
_lang = self._lang,
getCategoryName = function(self) return "Requests (" .. self._lang:getCanonicalName() .. ")" end,
getDescription = function(self) return self._lang:getCanonicalName() .. " entries that need attention of experienced editors." end,
}, sort = "requests"})
table.insert(ret, {name = {
_lang = self._lang,
getCategoryName = function(self) return "User " .. self._lang:getCode() end,
getDescription = function(self) return "Wiktionary users categorized by fluency levels in " .. self._lang:getCanonicalName() .. "." end,
}, sort = "user"})
return ret
end
function Category:getBild()
return nil
end
function Category:getUmbrella()
return nil
end
return export