Mòdul:arn-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]


Mòdul de suport per la plantilla {{arn-entrada}}. Mostra l’entrada, sigui lema o forma, i la seva ortografia. Vegeu la documentació de la plantilla per a més informació.

local p = {}

local lang = {code = "arn", name = "mapudungu", sc = "Latn"}

local function posCat(pos, head)
	-- 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 or mw.title.getCurrentTitle().text, "[^ ] [^ ]")
	
	local pos_cat
	
	if form then
		pos = string.sub(pos, 1, form - 1)
	end
	if pos_abrev[pos] then
		pos_cat = pos_abrev[pos]
	else
		pos_cat, _ = require("Mòdul:ca-lema").forma_plural_nominal(pos, "-")
	end
	
	if loc and pos_loc[pos_cat] then
		if form then
			pos_cat = "Formes de locucions " .. pos_loc[pos_cat]
		else
			pos_cat = "Locucions " .. pos_loc[pos_cat]
		end
	elseif form then
		if pos_cat == "verbs" then
			pos_cat = "Formes verbals"
		elseif string.find(pos_cat, "^[aeiou]") then
			pos_cat = "Formes d'" .. pos
		else
			pos_cat = "Formes de " .. pos
		end
	else
		pos_cat = string.upper(string.sub(pos_cat, 1, 1)) .. string.sub(pos_cat, 2)
	end
	
	return pos_cat
	
end

function p.spelling(frame)
	local args = frame:getParent().args
	pagename = args.pagename or mw.title.getCurrentTitle().subpageText
	
	local data = {lang = lang, heads = {}, genders = {}, inflections = {}, categories = {}}
	local lema = args.lema; if lema == "" then lema = nil end
	table.insert(data.heads, lema)
	if args[1] then
		table.insert(data.categories, posCat(args[1], pagename) .. " en " .. lang.name)
	end
	
	local spelling_to_type = { -- [code] = {label, Wikipedia section, category}
		["u"] = {"Unificat", "Alfabet Maputxe Unificat (AMU)", "Alfabet Maputxe Unificat"},
		["r"] = {"Raguileo", "Grafemario Raguileo", "Grafemario Raguileo"},
		["n"] = {"Ñeweñ", "Escriptura Ñeweñ", "Escriptura Ñeweñ"},
		["a"] = {"Azümchefe", "Azümchefe", "Ortografia Azümchefe"}
	}
	for typ in mw.text.gsplit(args.ort or '', '') do
		if spelling_to_type[typ] then
			table.insert(data.inflections, {label = "[[w:Alfabet mapudungun#" .. spelling_to_type[typ][2] .. "|" .. spelling_to_type[typ][1] .. "]]"})
			table.insert(data.categories, spelling_to_type[typ][3])
		elseif typ ~= '' then
			error("Tipus d'ortografia mapugundu no reconegut: " .. typ)
		end
	end
	
	return require("Mòdul:lema").full_headword(data)
end

return p