Module:eo-conj

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local lang = require("Module:languages").getByCode("eo")

local p = {}

function p.init(frame)
	local intr = frame:getParent().args["intr"]
	local root = frame:getParent().args["root"]
	if not root then
	    local pagename = tostring( mw.title:getCurrentTitle() )
	    root = string.sub(pagename, 0, -2)
	end
    return p.conj(root, intr)
end

function p.conj(root, intr)
	local function link(affix)
		return require("Module:links").full_link({lang = lang, accel = {form = affix}, term = root .. affix})
	end
	
	local function row(r)
		return ""
	end
	
	local t = {"a", "i", "o"}
	
	local val = [=[<div class="eo-conj-wrapper"><div class="NavFrame">
<div class="NavHead">Conjugation of <span lang="eo">]=] .. root .. [=[i</span></div>
<div class="NavContent">
{| class="inflection-table eo-conj"
|-
|rowspan=2 colspan=2|[[Image:Esperanto star.svg|30px|link=|alt=]]
! colspan=2|present 
! colspan=2|past 
! colspan=2|future
|-
! singular
! plural
! singular
! plural
! singular
! plural]=]
	local function threecells(preword, affix)
		val = val .. "\n|-\n! colspan=2| " .. preword
		for i = 1, 3, 1 do
			val = val .. "\n| colspan=2|" .. link(t[i] .. affix)
		end
	end
	threecells("tense", "s")
	for i = 1, 8, 1 do
		if ( i - 1 ) % 4 < 2 or intr ~= "yes" then
			local act = ( i - 1 ) % 4 > 1 and "" or "n"
			local nom = i > 4 and "o" or "a"
			local acc = ""
			if i % 2 == 0 then
				acc = "n"
				val = val .. "\n|-\n! <span title=\"accusative\">acc.</span>"
			else
				val = val .. "\n|-\n! rowspan=2| "
				if i > 4 then val = val .. "nominal " end
				if act == "" then val = val .. "passive" else val = val .. "active" end
			
				val = val .. " participle\n!"
			end
		
			for ii = 1, 6, 1 do
				val = val .. "\n| " .. link( t[ math.ceil( ii / 2 ) ] .. act .. "t" .. nom .. (ii % 2 == 0 and "j" or "") .. acc )
			end
		end
	end
	threecells("adverbial active participle", "nte")
	if intr ~= "yes" then threecells("adverbial passive participle", "te") end
	
val = val .. [=[ 
|}
{| class="inflection-table eo-conj eo-conj-bottom"
|-
!colspan="2" | infinitive
|colspan="6" | <span lang="eo">''']=] .. root .. [=[i'''</span>
!colspan="2" | imperative 
|colspan="6" | ]=] .. link("u") .. [=[ 
!colspan="2" | conditional
|colspan="6" | ]=] .. link("us") .. [=[ 
|}
</div></div></div>]=]
	
	return require "Module:TemplateStyles"("Module:eo-conj/style.css") .. "\n" .. val
end


return p