Moduł:forma fleksyjna

Z Wikisłownika – wolnego słownika wielojęzycznego

Moduł obsługuje wszystkie formy fleksyjne. Wywoływany jest za pomocą szablonów dla poszczególnych części mowy, znajdujących się na tej liście.

Zobacz też:

local p = {}

local errorcat = 'Nieznany kod języka (formy fleksyjne)'

p.export = function( frame )
	local args  = frame.args
	local pargs = frame:getParent().args
	
	local wordclass  = args[ 1 ]
	local wordclassG = args[ 2 ]
	local errorcode  = args[ 3 ]
	local phrase     = args.fraza
	
	local id = pargs[ 1 ] or nil
	local currenttitle = mw.title.getCurrentTitle()
	
	local ismain = currenttitle:inNamespace( 0 )
	local title  = currenttitle.text
	local isDictPage = ((mw.ustring.find(title, 'Słownik ', 1, true)) == 1)
	
	wordclass = ( phrase and ismain and ( string.find( title, ' ' ) ) )
		and 'fraza ' .. phrase
		or  wordclass
	
	local label = mw.html.create( 'i' ):wikitext(
		wordclass .. ', ' ..
		( ( pargs[ 'rodzaj' ] and pargs[ 'rodzaj' ] ~= '' )
			and 'rodzaj ' .. pargs[ 'rodzaj' ] .. ', '
			or  ''
		) ..
		'forma fleksyjna'
	)
	
	local cat = ''
	
	if ismain and not isDictPage then
		local lang = require( 'Module:forma fleksyjna/dane' )[ id ]
		
		if lang then
			local catname = string.gsub( lang, '*', wordclassG )

			if mw.title.new( catname, 'Kategoria' ).exists then
				cat = '[[Kategoria:' .. catname .. ']]'
			else
				cat = '[[Kategoria:' .. errorcat .. '|' .. errorcode .. ']]'
			end
		else
			cat = '[[Kategoria:' .. errorcat .. '|N]]'
		end
	end

	return tostring( label ) .. cat
end

return p