Module:hy-common

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:hy-common/documentation. [edit]
Useful links: subpage listtransclusionstestcases
Text-x-generic with pencil.svg This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

--[[
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.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