پودمان: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 = {}
local yesno = require('Module:Yesno') -- boolean value interpretation
--[[
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 "اُمین".
sup: Set to yes/no to toggle superscript ordinal suffix.
]]
function p.ordinal(frame)
local args = frame.args
local suffix = "اُمین"
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] == 'م'), yesno(args.sup))
end
function p._ordinal(n, d, sup)
local suffix = "اُمین"
if d then
suffix = "اُم"
end
if sup then
suffix = "<sup>" .. suffix .. "</sup>"
end
return n .. suffix
end
return p