Module:Plural

Iz Medžuviki, svobodnoj encyklopedije
Jump to navigation Jump to search

Nema teksta dokumentacije.

--
-- Module for Interslavic plurals
-- Source: http://steen.free.fr/interslavic/numerals.html
--
local p = {}

-- For usage in other modules
function p._plural(num, sing, pl_nom, pl_gen)
	num = tonumber( num )
	if num == nil then
		return '[Not a number.]'
	end
	num = math.floor(num + 0.5)
	
	sing = sing or ''
	pl_nom = pl_nom or sing or ''
	pl_gen = pl_gen or pl_nom or ''
	
	if num == 1 then
		return sing
	end
	
	if num == 2 or num == 3 or num == 4 then
		return pl_nom
	end
	
	return pl_gen
end

-- For usage in templates
function p.plural(frame)
	local args = frame.args
	local num = args[1]
	
	local sing = args[2]
	local pl_nom = args[3]
	local pl_gen = args[4]
	
	return p._plural(num, sing, pl_nom, pl_gen)
end

return p