Mòdul:ro-entrada

De Viccionari
Icona de documentació de mòdul Documentació del mòdul[mostra] [modifica] [refresca]

A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]


Aquest mòdul presenta la capçalera d’una entrada en romanès amb el gènere, la flexió i la categoria corresponent a la categoria gramatical. Actualment dóna suport a la plantilla {{ro-nom}}. Vegeu la documentació de les plantilles per a la seva utilització.

local p = {}

local m_headword = require("Mòdul:lema")
local lang = {code = "ro", name = "romanès", sc = "Latn"}
local pos_functions = {}

function p.flex(frame)
	local args = frame:getParent().args
	pagename = args.pagename
	if not pagename or pagename == "" then
		pagename = mw.title.getCurrentTitle().subpageText
	end
	
	local data = {lang = lang, heads = {}, genders = {}, inflections = {}, categories = {}}
	local lema = args.lema; if lema == "" then lema = nil end
	table.insert(data.heads, lema)

	local poscat = frame.args[1] or error("Falta especificar la categoria lèxica com a primer paràmetre.")
	if pos_functions[poscat] then
		pos_functions[poscat].func(args, data)
	else
		table.insert(data.categories, poscat .. " en " .. lang.name)
	end
	if args.cat and args.cat ~= "" then
		table.insert(data.categories, args.cat)
	end
	
	return m_headword.full_headword(data)
end

-- Informació de flexió per a substantius
pos_functions["Substantius"] = {func = function(args, data)
	local genere = args[1]; if genere == "" then genere = nil end
	local genere2 = args.g2; if genere2 == "" then genere2 = nil end
	local plural = args[2]; if plural == "" then plural = nil end
	local plural2 = args.p2; if plural2 == "" then plural2 = nil end
	local femeni = args.f; if femeni == "" then femeni = nil end
	local masculi = args.m; if masculi == "" then masculi = nil end
	
	table.insert(data.genders, (genere and genere or "?") .. (genere2 and "-" .. genere2 or "") )
	
	if mw.ustring.find(pagename, "[^ ]+ [^ ]+") then
		table.insert(data.categories, "Locucions nominals en romanès")
	else
		table.insert(data.categories, "Substantius en romanès")
	end
	
	if plural then
		if plural == "-" then
			table.insert(data.inflections, {label = "sense plural"})
		elseif plural ~= "?" then
			local infl_parts = {label = "plural", accel = "plural-form-of"}
			table.insert(infl_parts, plural)
			if plural2 then
				table.insert(infl_parts, plural2)
			end
			table.insert(data.inflections, infl_parts)
		end
	end
	
	if femeni then
		table.insert(data.inflections, {label = "femení", femeni})
	end
	
	if masculi then
		table.insert(data.inflections, {label = "masculí", masculi})
	end

	return
end
}

return p