Module:Esperanto Translation/Objektujo/Alinomoj/Tabelo

Jump to navigation Jump to search
Documentation[create] [refresh]
This module has no documentation. If you know how to use this module, please create it.
local p = {}
p.tabelo = function()
	local slot = require( [[Module:Esperanto Translation/Objektujo]] )
	local aliases = mw.loadData( [[Module:Esperanto Translation/Objektujo/Alinomoj]] )

	local aliasNames = {}
	local aI = 1
	for name in pairs( aliases ) do
		-- Alinomoj pri standardoj, krom "Iu ajn standardo", estas
		-- foriginda, ĉar estas tiom ke la tabelo estus tro longa
		if
			name == 'Iu ajn standardo' or
			not name:find( ' standardo$' ) and
			not name:find( '^Laŭa ' ) or
			not aliases[name:gsub( '^Laŭa', 'Iu ajn' )]
		then
			aliasNames[aI] = name
			aI = aI + 1
		end
	end
	table.sort( aliasNames )

	local tableRows = {
		' {| class="wikitable collapsible collapsed"',
		'! Alinomo !! Rezulto'
	}
	local rI = #tableRows + 1
	for _, name in ipairs( aliasNames ) do
		local alias = slot.getAlias( aliases[name], {} )

		local cell = {}
		for i, frame in ipairs( alias ) do
			cell[i] = slot.ujo{ { frame }, parsed = true }
		end

		local aliasText = mw.html.create()
		aliasText:tag( 'code' ):wikitext( name )
		if name:find( '^Iu ajn ' ) then
			local altName = name:gsub( '^Iu ajn', 'Laŭa' )
			if aliases[altName] then
				aliasText:tag( 'br' ):done()
					:tag( 'code' ):wikitext( altName )
			end
		end

		tableRows[rI] = '|' .. tostring( aliasText ) .. '||' .. table.concat( cell )
		rI = rI + 1
	end
	tableRows[rI] = '|}'

	return table.concat( tableRows, '\n|-\n' )
end
return p