Module:strConversion

E Victionario
Jump to navigation Jump to search

Usus[+/-]


-- Module:strConversion
-- 2018-08-01 -- V5.1 -- +adverbium
-- {{#invoke:strConversion|laConvert|{{{1}}}}}
-- laConvert: Converting Latin string into text string without diacritics.
-- Recognized characters: Ā ā Ă ă Ē ē Ĕ ĕ Ë ë Ī ī Ĭ ĭ Ō ō Ŏ ŏ Ū ū Ŭ ŭ Û û Ȳ ȳ Y̆ y̆ 
-- {{#invoke:strConversion|inversio|{{{1}}}}}
-- laAncora: Replacing all tokens found in xTab.
-- inversio: Inverting all character positions of a string.

local export = {}

local cvTab =
	{
	["Ā"]='A', ["ā"]='a', ["Ă"]='A', ["ă"]='a', ["Ē"]='E', ["ē"]='e', ["Ĕ"]='E', ["ĕ"]='e', ["Ë"]='E', ["ë"]='e',  
	["Ī"]='I', ["ī"]='i', ["Ĭ"]='I', ["ĭ"]='i', ["Ō"]='O', ["ō"]='o', ["Ŏ"]='O', ["ŏ"]='o',  
	["Ū"]='U', ["ū"]='u', ["Ŭ"]='U', ["ŭ"]='u', ["Û"]='U', ["û"]='u', ["Ȳ"]='Y', ["ȳ"]='y',
	}

local xTab =
	{
	["adiectivum"]="adj",
	["adverbium"]="adv",
	["coniunctio"]="con",
	["gerundivum"]="gndv",  
	["interiectio"]="int",
	["intransitivum"]="intr",
	["participium"]="par",
	["praepositio"]="prae",
	["pronomen"]="pron",
	["proprium"]="prop",
	["substantivum"]="sub",
	["transitivum"]="tran",
	["verbum"]="verb",
	}

function export.laConvert(frame)
	return laString(frame.args[1])
end

function export.laAncora(frame)
	return xTab[frame.args[1]]
end

function laString(str)
	local newstr = ""
	newstr = mw.ustring.gsub(str, '.', cvTab)
	newstr = mw.ustring.gsub(newstr, 'Y̆', 'Y')
	newstr = mw.ustring.gsub(newstr, 'y̆', 'y')
	return newstr
end

function export.inversio(frame)
	local newstr = ""
	for i = mw.ustring.len( frame.args[1] ), 1, -1 do
        newstr = newstr .. mw.ustring.char(mw.ustring.codepoint(frame.args[1],i))
	end
	return newstr
end

return export

-- End of Module:strConversion