Modulo:Ordinal

Manipud iti Wikipedia, ti nawaya nga ensiklopedia
Darsen a mapan iti pagdaliasatan Darsen a mapan agbiruk
Dokumentasion ti modulo[kitaen] [urnosen] [pakasaritaan] [purgaen]

Isayangkat daytoy a modulo ti {{Ordinal}}.

--[[  
 
This template will add the appropriate ordinal prefix to a given integer.
 
Please do not modify this code without applying the changes first at
Module:Ordinal/sandbox and testing at Module:Ordinal/sandbox/testcases and
Module talk:Ordinal/sandbox/testcases.
 
]]

local p = {}

--[[
This function converts an integer value into a numeral followed by ordinal indicator.
The output string might contain HTML tags.
 
Usage:
{{#invoke:Ordinal|ordinal|1=}}
{{#invoke:Ordinal|ordinal}} - uses the caller's parameters
 
Parameters
    1: Any number or string.
]]
function p.ordinal(frame)
	local args = frame.args
    if args[1] == nil then
        args = frame:getParent().args
    end
    if args[1] == nil then
    	args[1] = "{{{1}}}"
    end
    return p._ordinal(args[1])
end

function p._ordinal(n)
	local x = tonumber(mw.ustring.match(n, "(%d*)%W*$"))
	local prefix = "maika-"
	if x then
		if x == 1 then
			return "umuna"
		end
	end
	return prefix .. n
end

return p