Modul:Ordinal
Tampilan
Dokumentasi untuk modul ini dapat dibuat di Modul:Ordinal/doc
--[[
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 = "ke-"
return prefix .. n
end
return p