پودمان:Ordinal/تمرین
اینجا صفحهٔ تمرین پودمان برای پودمان:Ordinal (تفاوت) است. همچنین زیرصفحه همنشین برای نمونههای آزمایشی (اجرا) را ببینید. |
--[[
This template will add the appropriate ordinal suffix 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=|2=}}
{{#invoke:Ordinal|ordinal}} - uses the caller's parameters
Parameters
1: Any number or string.
2: Set to "م" if the module should display "م" instead of "مین".
]]
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], args[2])
end
function p._ordinal(n)
local suffix = "مین"
if args[2] == "م" then
suffix = "م"
end
return n .. suffix
end
return p