A modult a Modul:hy-common/doc lapon tudod dokumentálni

--[[
This module holds some commonly used functions for the Armenian language. It is for use from other modules, not #invoke.
]]

local export = {}

--find if the last letter is a vowel, so that the declension template can suppress a certain impossible inflected form

function export.vowend(frame)
	local vowels = {
		["ա"] = true,
		["ե"] = true,
		["է"] = true,
		["ի"] = true,
		["ո"] = true,
		["օ"] = true,
		["ո"] = true,
	}
	local vowels2 = {["ու"] = true}
	
	local pagename = frame.args[1]
	
	if vowels[mw.ustring.sub(pagename, -1)] then
		return "[["..pagename.."ն]]"
	end
	
	if vowels2[mw.ustring.sub(pagename, -2)] then
		return "[["..pagename.."ն]]"
	end

	return "[["..pagename.."ը]]/[["..pagename.."ն]]"
end

--remove the ending -ել/ալ

function export.elal(frame)
	local pagename = frame.args[1]
	return mw.ustring.sub(pagename,1,-3)
end

--remove the ending -ցնել

function export.cnel(frame)
	local pagename = frame.args[1]
	return mw.ustring.sub(pagename,1,-5)
end

--remove the ending -ություն

function export.utyun(frame)
	local pagename = frame.args[1]
	return mw.ustring.sub(pagename,1,-8)
end

--remove the ending -ութիւն

function export.utiwn(frame)
	local pagename = frame.args[1]
	return mw.ustring.sub(pagename,1,-7)
end

--remove the ending -ի for u-declension nouns

function export.i(frame)
	local lastvowel = {["ի"] = true}
	local pagename = frame.args[1]
	
	if lastvowel[mw.ustring.sub(pagename, -1)] then
		return mw.ustring.sub(pagename,1,-2)
	end

	return ""..pagename..""
end
	--insert the glide -յ- for nouns ending in -a and -o

function export.glide(frame)
	local vowels = {
		["ա"] = true,
		["ո"] = true,
		["օ"] = true,
	}
	
	local pagename = frame.args[1]
	
	if vowels[mw.ustring.sub(pagename, -1)] then
		return "յ"
	end
end

return export