Moduł:Drzewa link: Różnice pomiędzy wersjami
Z Nonsensopedii, polskiej encyklopedii humoru
M |
M |
||
Linia 33: | Linia 33: | ||
['nonźródła']='nonźródła'} |
['nonźródła']='nonźródła'} |
||
local args = tools.getArgs(frame) |
local args = tools.getArgs(frame) |
||
local |
local _namespaces = {} |
||
local |
local _cats = {} |
||
for index, cat in ipairs(args) do |
for index, cat in ipairs(args) do |
||
if cat == nil then return 'cat - nil' end |
if cat == nil then return 'cat - nil' end |
||
namespace = namespaces_[cat:match("(.+) – "):lower()] or 'główna' |
namespace = namespaces_[cat:match("(.+) – "):lower()] or 'główna' |
||
table.insert( |
table.insert(_namespaces, namespace) |
||
table.insert( |
table.insert(_cats, cat) |
||
end |
end |
||
return table.concat( |
return table.concat(_namespaces, ', ') .. table.concat(_cats, ', ') |
||
-- return frame:expandTemplate(p._linkCats(namespaces, cats)) |
-- return frame:expandTemplate(p._linkCats(namespaces, cats)) |
||
end |
end |
Wersja z 12:46, 2 gru 2020
local p = {}
local tools = require('Moduł:Narzędzia')
function p._linkCats(namespaces, categories)
local comms = {['główna'] = 'artykułów', ['grafiki'] = 'grafik',
['nonnews'] = 'NonNewsów', ['słownik'] = 'haseł słownikowych',
['cytaty'] = 'cytatów', ['poradniki'] = 'poradników',
['nonźródła'] = 'nonźródeł'}
if #categories < 2 then
local use_plural = false else local use_plural = true end
if use_plural then
treessuf = 'ie' else treessuf = 'ach' end
local catlinks = {}
for i=1, #namespaces do
local namespace = namespaces[i]
local category = categories[i]
local link = comms[namespace] .. ': \'\'\'' ..
'[[:Kategoria:' .. category .. ']]' .. '\'\'\''
table.insert(catlinks, link) end
return {title='Ambox', args={
grafika='[[Plik:Dwa drzewa kategorii.svg|x40px]]',
tekst='Ta kategoria ma swój odpowiednik w drzew' .. treessuf
.. ' kategorii ' .. table.concat(catlinks, ', ') .. '.'}}
end
function p.linkCats(frame)
local namespaces_ =
{['główna']='główna', ['grafiki']='grafiki', ['nonnews']='nonnews',
['słownik']='słownik', ['cytaty']='cytaty', ['poradniki']='poradniki',
['nonźródła']='nonźródła'}
local args = tools.getArgs(frame)
local _namespaces = {}
local _cats = {}
for index, cat in ipairs(args) do
if cat == nil then return 'cat - nil' end
namespace = namespaces_[cat:match("(.+) – "):lower()] or 'główna'
table.insert(_namespaces, namespace)
table.insert(_cats, cat)
end
return table.concat(_namespaces, ', ') .. table.concat(_cats, ', ')
-- return frame:expandTemplate(p._linkCats(namespaces, cats))
end
return p