Module:uk-common

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

local export = {}
 
function export.needs_accents(word)
	if mw.ustring.find(word, "\204\129") then
		return false
	-- A word needs accents if it contains more than one vowel
	elseif mw.ustring.find(mw.ustring.lower(word), "[аеєиіїоуюя].*[аеєиіїоуюя]") then
		return true
	else
		return false
	end
end
 
-- Handles the alternation between initial і/у and й/в.
function export.initial_alternation(word, previous)
	if mw.ustring.find(word, "^і") or mw.ustring.find(word, "^й[^аеиоуяєію]") then
		if mw.ustring.find(previous, "[аеиоуяєіїю́]$") then
			return mw.ustring.gsub(word, "^[ій]", "й")
		else
			return mw.ustring.gsub(word, "^[ій]", "і")
		end
	elseif mw.ustring.find(word, "^у") or mw.ustring.find(word, "^в[^аеиоуяєію]") then
		if mw.ustring.find(previous, "[аеиоуяєіїю́]$") then
			return mw.ustring.gsub(word, "^[ув]", "в")
		else
			return mw.ustring.gsub(word, "^[ув]", "у")
		end
	end
 
	return word
end
 
return export