Модуль:category tree/langcatboiler
Бул модулда ишке {{langcatboiler}}. Бул жерде документтерди модулу иштейт, жана кандай, же өзгөртө категория дарактын маалыматты алып кантип сүрөттөйт. шаблон өзү кантип колдонуу керектиги жөнүндө маалымат алуу үчүн, анын документтерин карап көргүлө.
Бул модулда бренды колдоно бербейт. Натыйжалуу, анын маалымат кыйын-код модулу салып, бир гана белги жок.
local export = {}
local function linkbox(lang, setwiki, setsister, entryname)
local wiktionarylinks = "''None.''"
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-en.svg|35px|none|Wiktionary]]
|| '']=] .. lang:getCategoryName() .. [=[ edition]=] .. (#lang:getWikimediaLanguages() > 1 and "s" or "") .. [=[ of Wiktionary''
|-
| colspan="2" style="padding-left:10px" | ]=] .. wiktionarylinks .. [=[
|-
| style="vertical-align: Middle; height: 35px" | [[File:Wikipedia-logo.png|35px|none|Wikipedia]]
|| ''Wikipedia article about ]=] .. lang:getCategoryName() .. [=[''
|-
| colspan="2" style="padding-left:10px" | ]=] .. (setwiki == "-" and "''None.''" or "'''[[w:" .. (setwiki or lang:getCategoryName()) .. "|" .. (setwiki or lang:getCategoryName()) .. "]]'''") .. [=[
|-
| style="vertical-align: Middle; height: 35px" | [[File:Wikimedia-logo.svg|35px|none|Wikimedia Commons]]
|| ''Links related to ]=] .. lang:getCategoryName() .. [=[ in sister projects at 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() .. [=[ considerations
|-
| colspan="2" style="padding-left:10px" | '''[[Wiktionary:About ]=] .. 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() .. [=[ entry
|-
| colspan="2" style="padding-left:10px" | ''']=] .. require("Module:links").full_link({lang = require("Module:languages").getByCode("en"), term = entryname or lang:getCanonicalName()}) .. [=['''
|}
</div>]=]
end
local function infobox(lang)
local ret = ""
ret = ret .. "<table class=\"wikitable\">\n"
ret = ret .. "<tr>\n<th colspan=\"2\" class=\"plainlinks\">[//en.wiktionary.org/w/index.php?title=Module:" .. require("Module:languages").getDataModuleName(lang:getCode()) .. "&action=edit Edit language data]</th>\n</tr>\n"
ret = ret .. "<tr>\n<th>Canonical name</th><td>" .. lang:getCanonicalName() .. "</td>\n</tr>\n"
if #lang:getOtherNames() > 0 then
local names = {}
for _, name in ipairs(lang:getOtherNames()) do
table.insert(names, "<li>" .. name .. "</li>")
end
ret = ret .. "<tr>\n<th>Other names</th><td>" .. table.concat(names, "\n") .. "</td>\n</tr>\n"
end
ret = ret .. "<tr>\n<th>[[Wiktionary:Languages|Language code]]</th><td><code>" .. lang:getCode() .. "</code></td>\n</tr>\n"
ret = ret .. "<tr>\n<th>[[Wiktionary:Families|Language family]]</th>\n"
local fam = lang:getFamily()
if not fam then
ret = ret .. "<td>unclassified</td>"
elseif fam:getCode() == "qfa-iso" then
ret = ret .. "<td>[[:Category:Language isolates|language isolate]]</td>"
elseif fam:getCode() == "qfa-mix" then
ret = ret .. "<td>[[:Category:Mixed languages|mixed language]]</td>"
elseif fam:getCode() == "sgn" then
ret = ret .. "<td>[[:Category:Sign languages|sign language]]</td>"
elseif fam:getCode() == "crp" then
ret = ret .. "<td>[[:Category:Creole or pidgin languages|creole or pidgin]]</td>"
elseif fam:getCode() == "art" then
ret = ret .. "<td>[[:Category:Constructed languages|constructed language]]</td>"
else
ret = ret .. "<td>[[:Category:" .. fam:getCategoryName() .. "|" .. fam:getCanonicalName() .. "]]</td>"
end
if #lang:getAncestors() > 0 then
for _, anc in ipairs(lang:getAncestors()) do
ret = ret .. "[[Category:" .. anc:getCategoryName() .. "]]"
end
end
ret = ret .. "\n</tr>\n<tr>\n<th>Ancestors</th>\n"
if #lang:getAncestors() > 1 then
local ancestors = {}
for _, anc in ipairs(lang:getAncestors()) do
table.insert(ancestors, "<li>[[:Category:" .. anc:getCategoryName() .. "|" .. anc:getCanonicalName() .. "]]</li>")
end
ret = ret .. "<td><ul>\n" .. table.concat(ancestors, "\n") .. "</ul></td>\n"
elseif #lang:getAncestorChain() > 0 then
ret = ret .. "<td><ul>\n"
local chain = {}
for _, anc in ipairs(lang:getAncestorChain()) do
table.insert(chain, "<li>[[:Category:" .. 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>unknown</td>\n"
end
ret = ret .. "</tr>\n"
if #lang:getScripts() > 0 then
local scripts = {}
for _, sc in ipairs(lang:getScripts()) do
local text = "<li>[[:Category:" .. 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>[[:Category:" .. Hani:getCategoryName() .. "|" .. Hani:getCanonicalName() .. "]]</li>\n" ..
"<li>[[:Category:" .. Hira:getCategoryName() .. "|" .. Hira:getCanonicalName() .. "]]</li>\n" ..
"<li>[[:Category:" .. 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>[[:Category:" .. Hang:getCategoryName() .. "|" .. Hang:getCanonicalName() .. "]]</li>\n" ..
"<li>[[:Category:" .. Hani:getCategoryName() .. "|" .. Hani:getCanonicalName() .. "]]</li>\n" ..
"</ul>\n"
end
text = text .. "</li>"
table.insert(scripts, text)
end
ret = ret .. "<tr>\n<th>[[Wiktionary:Scripts|Scripts]]</th>\n<td><ul>\n" .. table.concat(scripts, "\n") .. "</ul></td>\n</tr>\n"
else
ret = ret .. "<tr>\n<th>[[Wiktionary:Scripts|Scripts]]</th>\n<td>not specified</td>\n</tr>\n"
end
ret = ret .. "</table>"
return ret
end
function export.country_categories(frame)
local categories = {}
for i, country in ipairs(frame:getParent().args) do
if i > 1 then
table.insert(categories, "[[Category:Languages of " .. country .. "]]")
end
end
if #categories > 0 then
return table.concat(categories)
else
return "[[Category:Languages not sorted into a country category]]"
end
end
-- Category object
local Category = {}
Category.__index = Category
function Category.new(info)
for key, val in pairs(info) do
if not (key == "code" or key == "entryname" or key == "setsister" or key == "setwiki" or key == "setwikt") then
error("The parameter \"" .. key .. "\" was not recognized.")
end
end
local self = setmetatable({}, Category)
self._info = info
if not self._info.code then
error("No language code was specified.")
else
self._lang = require("Module:languages").getByCode(self._info.code) or error("The language code \"" .. val .. "\" is not valid.")
end
return self
end
export.new = Category.new
function Category:getInfo()
return self._info
end
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:isHidden()
return false
end
function Category:getCategoryName()
return mw.getContentLanguage():ucfirst(self._lang:getCategoryName())
end
function Category:getDescription()
if self._lang:getCode() == "und" then
return
"Бул негизги категория болуп саналат '''" .. self._lang:getCategoryName() .. "''', [[Wiktionary:Languages|кодексинде]] Wiktionary көрсөтүлгөн '''" .. self._lang:getCode() .. "'''. " ..
"Бул тил мааниси дагы аалымдар тарабынан аныкталган эмес тарыхый жазуу, терминдерди камтыйт."
end
local ret = linkbox(self._lang, self._info.setwiki, self._info.setsister, self._info.entryname)
ret = ret .. "Бул негизги категория болуп саналат '''" .. self._lang:getCategoryName() .. "'''.\n\nInformation about " .. self._lang:getCanonicalName() .. ":\n\n" .. infobox(self._lang)
if self._lang:getType() == "кайра" 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 Reconstruction: 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 [[Appendix:" .. self._lang:getCanonicalName() .. "]]."
end
local about = mw.title.new("Wiktionary:About " .. self._lang:getCanonicalName())
if about.exists then
ret = ret .. "\n\n" ..
"Please see '''[[Wiktionary:About " .. self._lang:getCanonicalName() .. "]]''' for information and special considerations for creating " .. self._lang:getCategoryName() .. " entries."
end
return ret
end
function Category:getParents()
local ret = {{name = "Category:All languages", sort = self._lang:getCanonicalName()}}
local fam = self._lang:getFamily()
if not fam then
table.insert(ret, {name = "Category:Unclassified languages", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "qfa-iso" then
table.insert(ret, {name = "Category:Language isolates", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "qfa-mix" then
table.insert(ret, {name = "Category:Mixed languages", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "sgn" then
table.insert(ret, {name = "Category:All sign languages", sort = self._lang:getCanonicalName()})
elseif fam:getCode() == "crp" then
table.insert(ret, {name = "Category:Creole or pidgin languages", sort = self._lang:getCanonicalName()})
for _, anc in ipairs(self._lang:getAncestors()) do
table.insert(ret, {name = "Category:" .. anc:getCanonicalName() .. "-based creole or pidgin languages", sort = self._lang:getCanonicalName()})
end
elseif fam:getCode() == "art" then
if self._lang:getType() == "appendix-constructed" then
table.insert(ret, {name = "Category:Appendix-only constructed languages", sort = self._lang:getCanonicalName()})
else
table.insert(ret, {name = "Category:Constructed languages", sort = self._lang:getCanonicalName()})
end
for _, anc in ipairs(self._lang:getAncestors()) do
table.insert(ret, {name = "Category:" .. anc:getCanonicalName() .. "-based constructed languages", sort = self._lang:getCanonicalName()})
end
else
table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(fam:getCategoryName()), sort = self._lang:getCanonicalName()})
if self._lang:getType() == "reconstructed" then
table.insert(ret, {name = "Category:Reconstructed languages", sort = (mw.ustring.gsub(self._lang:getCanonicalName(), "^Proto%-", ""))})
end
end
for _, sc in ipairs(self._lang:getScripts()) do
table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(sc:getCategoryName() .. " тили"), sort = self._lang:getCanonicalName()})
if sc:getCode() == "Jpan" then
table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hani"):getCategoryName() .. " тили"), sort = self._lang:getCanonicalName()})
table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hira"):getCategoryName() .. " тили"), sort = self._lang:getCanonicalName()})
table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Kana"):getCategoryName() .. " тили"), sort = self._lang:getCanonicalName()})
elseif sc:getCode() == "Kore" then
table.insert(ret, {name = "Category:" .. mw.getContentLanguage():ucfirst(require("Module:scripts").getByCode("Hang"):getCategoryName() .. " тили"), sort = self._lang:getCanonicalName()})
table.insert(ret, {name = "Category:" .. 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", "lemmas", "names", "phrases", "rhymes", "symbols", "templates", "terms by etymology", "terms by usage", "transliterations"}) do
local child = m_poscatboiler.new({code = self._lang:getCode(), label = label})
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 == "Category:" .. self:getCategoryName() then
table.insert(ret, {name = child, sort = parent.sort})
break
end
end
end
end
local m_derivcatboiler = require("Module:category tree/derivcatboiler")
local child = m_derivcatboiler.new({code = nil, label = self._lang:getCode()})
local sortkey = child._info.label
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 == "Category:" .. 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 topics"})
local sortkey = child._info.label
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 == "Category:" .. 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:getUmbrella()
return nil
end
return export