Module:Category described in year
Appearance
![]() | This Lua module is used on approximately 6,200 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
Related pages |
---|
Implements {{Category described in year}}
require('Module:No globals')
local p = {}
function p.autodetect( frame )
local currentTitle = mw.title.getCurrentTitle()
local categories = {}
local header = 'tbd; This category should only contain species articles, etc....'
local outString = 'something'
if currentTitle.namespace == 14 then --Category:
local cat = currentTitle.text --without namespace nor interwiki prefixes
local group = mw.ustring.match(cat, '^%w+')
local year = mw.ustring.match(cat, '%d%d%d%d$')
local century = ''
local ord = ''
if year then century = 1 + mw.ustring.match(year, '^%d%d') end
if century then
local lastd = mw.ustring.match(century, '%d$')
if lastd == 1 then ord = 'st'
elseif lastd == 2 then ord = 'nd'
elseif lastd == 3 then ord = 'rd'
else ord = 'th' end
end
if group and group == 'Fish' then
categories[1] = '[[Fish described in the ' .. century .. ord .. ' century]]' ..
'[[Animals described in ' .. year .. ']]'
end
elseif currentTitle.namespace == 10 then --Module:/Template: sandbox/testcases/doc
end
if string.sub(currentTitle.subpageText,1,9) == 'testcases' then
outString = outString .. mw.text.nowiki(table.concat(categories)) .. '<br />'
elseif currentTitle.namespace == 14 then --Category:
outString = outString .. table.concat(categories)
else
outString = ''
end
return outString
end
return p