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]


Mòdul de suport per la plantilla {{rom-entrada}}. Fa les mateixes funcions que Mòdul:lema/plantilles amb la inclusió de transliteracions ortogràfiques segons Viccionari:Alfabet romaní i desenvolupades a Mòdul:rom-trans.

local p = {}

local lang = {code = "rom", name = "romaní", sc = "Latn"}
local data = {lang = lang, heads = {}, genders = {}, categories = {}, inflections = {}}

-- Versió de Mòdul:lema/plantilles adaptada al romaní
function p.entrada(frame)
	local args = frame:getParent().args
	
	data.sort_key = args.ordre; if data.sort_key == "" then data.sort_key = nil end
	data.sc = args.sc or lang.sc
	
	-- Gather headwords
	local head = args.pagename or mw.title.getCurrentTitle().subpageText
	data.heads[1] = args.entrada or args.lema or args.pagename or ''
	
	-- Check spelling
	if data.sc == "Latn" then
		local Mtr = require("Mòdul:rom-trans")
		local sp = Mtr.spelling(head)
		if sp == "ac" or sp == "ang" then
			return "Per a ortografia alternativa a la internacional, useu {{rom-alt}}."
		else
			local sp_ac = args.ac or Mtr.academic(head)
			local sp_ang = args.ang or Mtr.anglicized(head)
			local sp_is_noacc = mw.ustring.gsub(mw.ustring.toNFD(head), mw.ustring.char(0x0300), "") -- grave
			local sp_ac_noacc = mw.ustring.gsub(mw.ustring.toNFD(sp_ac), mw.ustring.char(0x0301), "") -- acute
			if sp_ac_noacc ~= sp_is_noacc then
				table.insert(data.heads, "[[" .. sp_ac .. "]]")
			end
			if sp_ang ~= sp_is_noacc and sp_ang ~= sp_ac_noacc then
				table.insert(data.heads, "[[" .. sp_ang .. "]]")
			end
			if #data.heads > 1 then
				data.heads[#data.heads] = data.heads[#data.heads] .. " <sup><small>[[Viccionari:Alfabet romaní|(<strong>i</strong>)]]</small></sup>"
			end
		end
	end
	
	-- Gather gender and number specifications
	-- Iterate over all gn parameters (g2, g3 and so on) until one is empty
	local g = args.g; if g == "" then g = nil end
	local i = 2
	
	while g do
		table.insert(data.genders, g)
		g = args["g" .. i]; if g == "" then g = nil end
		i = i + 1
	end
	
	-- Part-of-speech category
	local langcat = " en " .. data.lang.name
	
	local pos = args[1]; if pos == "" then pos = nil end
	local cat = args.cat; if cat == "" then cat = nil end
	
	if cat then
		table.insert(data.categories, cat .. langcat)
	elseif pos then
		-- Make the plural form of the part of speech
		local pos_abrev = {["abr"]="abreviatures", ["adv"]="adverbis", ["adj"]="adjectius", ["conj"]="conjuncions", 
			["interj"]="interjeccions", ["nom"]="substantius", ["num"]="numerals", ["prep"]="preposicions", ["pron"]="pronoms"}
		local pos_loc = {["adverbis"]="adverbials", ["adjectius"]="adjectivals", ["conjuncions"]="conjuntives", 
			["interjeccions"]="interjectives", ["preposicions"]="prepositives", ["substantius"]="nominals", ["verbs"]="verbals"}
		local form = string.find(pos, "-forma", -6, true)
		local loc = string.find(head, "[^ ] [^ ]")
		
		if form then
			pos = string.sub(pos, 1, form - 1)
		end
		if pos_abrev[pos] then
			pos = pos_abrev[pos]
		else
			pos, _ = require("Mòdul:ca-lema").forma_plural_nominal(pos, "-")
		end
		
		if loc and pos_loc[pos] then
			if form then
				pos = "Formes de locucions " .. pos_loc[pos]
			else
				pos = "Locucions " .. pos_loc[pos]
			end
		elseif form then
			if pos == "verbs" then
				pos = "Formes verbals"
			elseif string.find(pos, "^[aeiou]") then
				pos = "Formes d'" .. pos
			else
				pos = "Formes de " .. pos
			end
		else
			pos = string.upper(string.sub(pos, 1, 1)) .. string.sub(pos, 2)
		end
		
		table.insert(data.categories, pos .. langcat)
	end
	
	-- Additional categories
	if args.cat2 then
		table.insert(data.categories, args.cat2 .. langcat)
	end
	
	if args.cat3 then
		table.insert(data.categories, args.cat3 .. langcat)
	end
	
	-- Inflected forms
	local i = 1
	local label = args[i * 2]
	local accel = args["f" .. i .. "accel"]; if accel == "" then accel = nil end
	local parts = {label = label, accel = accel}
	
	while label do
		local term = args[i * 2 + 1]; if term == "" then term = nil end
		local alt = args["f" .. i .. "alt"]; if alt == "" then alt = nil end
		local sc = args["f" .. i .. "sc"]; if sc == "" then sc = nil end
		local id = args["f" .. i .. "id"]; if id == "" then id = nil end
		local gender = args["f" .. i .. "g"]; if gender == "" then gender = nil end
		local qualifier = args["f" .. i .. "qual"]; if qualifier == "" then qualifier = nil end
		local nolink = args["f" .. i .. "nolink"]; if nolink == "" then nolink = nil end
		
		if term or alt then
			table.insert(parts, {term = term, alt = alt, sc = sc, id = id, translit = translit, genders = {gender}, qualifiers = {qualifier}, nolink = nolink})
		end
		
		i = i + 1
		label = args[i * 2]
		accel = args["f" .. i .. "accel"]; if accel == "" then accel = nil end
		
		-- If the next label is not "or" then insert the previous one and create a new one.
		if label ~= "o" then
			-- Only insert if the previous label is not empty.
			if (parts.label or "") ~= "" then
				table.insert(data.inflections, parts)
			end
			
			parts = {label = label, accel = accel}
		end
	end
	
	return require("Module:lema").full_headword(data)
end

function p.spelling(frame)
	local spelling_type = {
		['ac'] = 'grafia acadèmica', ['pv'] = 'grafia acadèmica',
		['ang'] = 'grafia anglicitzada', ['en'] = 'grafia anglicitzada'
	}
	
	local args = frame:getParent().args
	local spelling_abbrev = args[1] or ""
	local title = args[2]
	local gloss_text = args[3]
	
	local spelling_text = spelling_type[spelling_abbrev] or "grafia " .. spelling_abbrev
	
	local terminfo = {term = title, lang = lang, gloss = gloss_text}
	local sp_lang = {}
	sp_lang.code = spelling_text == 'grafia acadèmica' and "rom-x-pv" or "en"
	local categories = require("Mòdul:utilitats").format_categories({"Romaní amb " .. spelling_text}, sp_lang)
	
	return require("Module:forma flexionada").format_t(spelling_text .. " de ", terminfo, categories)
end	

return p