Jump to content

Module:Category described in year

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Tom.Reding (talk | contribs) at 18:01, 8 May 2018 (Create based on relevant discussions (very preliminary)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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