Modul:tcez

A Wikiszótárból, a nyitott szótárból

A modult a Modul:tcez/doc lapon tudod dokumentálni

local export = {}

local m_sc = require("Module:scripts")
local m_lang = require("Module:languages")

function export.show(frame)
	if #frame:getParent().args > 0 then error('No parameter should be passed') end
	PAGENAME = PAGENAME or mw.title.getCurrentTitle().text
	if PAGENAME:find(':') then --The names are designed to be ascii
		langcode = mw.text.split(PAGENAME,':')[1]
		catname = mw.text.split(PAGENAME,':')[2]
	else
		langcode = ''
		catname = PAGENAME
	end
	local text = ''
	if langcode ~= '' then
		local langname = m_lang.getByCode(langcode):getCanonicalName()
		text = text .. frame:expandTemplate{title='Template:topic cat description/'..catname,args={['langlink']='[['..langname..']]'}}
		text = text .. '<sup class="plainlinks">[[https://en.wiktionary.org/w/index.php?title=Template:topic_cat_description/'..mw.uri.encode(catname,'WIKI')..'&action=edit&preload=Template:topic_cat_description/default edit description]]'
		text = text .. '[[https://en.wiktionary.org/w/index.php?title=Template:topic_cat_parents/'..mw.uri.encode(catname,'WIKI')..'&action=edit&preload=Template:topic_cat_parents/preload edit parents]]</sup>'
		text = text .. "\n\n''For other languages, see table at'' [[:Category:"..catname.."]]"
		text = text .. '[[Category:'..catname..']]'
		text = text .. '[[Category:'..langcode..':List of topics]]'
	else
		text = text .. 'This category contains only other categories, no dictionary entries. Its subcategories are on the topic: '..catname..'. They are of two sorts:'
		text = text .. '\n\n* Subcategories named like "aa:'..catname..'" (with a prefixed language code) are categories of terms in specific languages; for example "fr:'..catname..'" is the '..catname..'-related category of French terms. You may be interested especially in [[:Category:en:'..catname..'|en:'..catname..']], for English terms. To browse by language name instead of language code, see the "By language" table, below.'
		text = text .. '\n\n* Subcategories of this one named without the prefixed language code are further categories just like this one, but devoted to topics finer than '..catname..'.'
		text = text .. '<sup class="plainlinks">[[https://en.wiktionary.org/w/index.php?title=Template:topic_cat_description/'..mw.uri.encode(catname,'WIKI')..'&action=edit&preload=Template:topic_cat_description/default edit description]]'
		text = text .. '[[https://en.wiktionary.org/w/index.php?title=Template:topic_cat_parents/'..mw.uri.encode(catname,'WIKI')..'&action=edit&preload=Template:topic_cat_parents/preload edit parents]]</sup>\n\n'
		text = text .. frame:expandTemplate{title='Template:nav table',args={['current']=catname}}
		text = text .. '[[Category:List of topics]]'
	end
	local parents = {}
	if mw.title.new('Template:topic cat parents/'..catname).exists then
		parents[1] = frame:expandTemplate{title='Template:topic cat parents/'..catname,args={'parent1',['code']=langcode,['label']=catname}}
		local asterisk = ''
		if langcode == '' then asterisk = '*' end
		if parents[1] ~= '' then
			text = text .. '[[' .. name(nil,langcode,parents[1]) .. '|' .. asterisk .. catname .. ']]'
		else
			local parentbyname1 = frame:expandTemplate{title='Template:topic cat parents/'..catname,args={'parentbyname1',['code']=langcode,['label']=catname}}
			if parentbyname1 ~= '' then
				text = text .. '[[' .. name(nil,langcode,parentbyname1) .. '|' .. asterisk
				local sortparent1 = frame:expandTemplate{title='Template:topic cat parents/'..catname,args={'sortparent1',['code']=langcode,['label']=catname}}
				if sortparent1 ~= '' then
					text = text .. sortparent
				else
					text = text .. catname
				end
				text = text .. ']]'
			end
		end
		for i=2,5 do
			parents[i] = frame:expandTemplate{title='Template:topic cat parents/'..catname,args={'parent'..i,['code']=langcode,['label']=catname}}
			if parents[i] ~= '' then
				text = text .. '[[' .. name(nil,langcode,parents[i]) .. '|' .. asterisk .. catname .. ']]'
			end
		end
	else
		text = text .. '[[' .. name(nil,langcode,'Miscellaneous') .. '|' .. asterisk .. catname .. ']]'
	end
	if langcode == '' then
		text = text .. '[[Category:List of topics|' .. catname .. ']]'
	else
		if catname ~= 'List of topics' then
			text = text .. '[[Category:'..catname..']]'
			text = text .. '[[Category:'..langcode..':List of topics|'..catname..']]'
		end
	end
	return text
end

function name(prefix,lang,category,sc)
	local text = prefix or 'Category:'
	if lang and lang ~= '' then text = text .. lang .. ':' end
	text = text .. category
	if sc and sc ~= '' then
		text = text .. ' in '
		if sc == 'Hant' then
			text = text .. 'traditional script'
		elseif sc == 'Hans' then
			text = text .. 'simplified script'
		else
			text = text .. m_sc.getByCode(sc):getCategoryName()
		end
	end
	return text
end

return export