Module:Sandbox/RexxS/Ordinal

-- Ordinals for Azerbaijani -- Takes a number and returns its ordinal.

local suffixes = { "ci", "ci", "cü", "cü", "ci", "cı", "ci", "ci", "cu", [0] = "cu", [10] = "cu", [20] = "ci", [30] = "cu", [40] = "cı", [50] = "ci", [60] = "cı", [70] = "ci", [80] = "ci", [90] = "cı" }

local function ordinal(number) local suffix if number == 0 then suffix = "cı" elseif number % 1000 == 0 then suffix = "ci" elseif number %100 == 0 then suffix = "cü" elseif number %10 == 0 then suffix = suffixes[number % 100] else suffix = suffixes[number %10] or "" end return number .. "-" .. suffix end

-- Just for testing by allowing a #invoke: call p = {}

function p.Ordinal(frame) number = tonumber(frame.args[1] or frame.args.number) or 0 return ordinal(number) end

return p