Skip to content

Commit

Permalink
feat: add to plural utility func
Browse files Browse the repository at this point in the history
  • Loading branch information
8char committed Aug 14, 2023
1 parent 034bfbe commit 4a8ab6e
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions laux/atlasui/libs/essentials_sh.laux
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,24 @@ function AtlasUI:HexToRGB(hex)
)
end

function AtlasUI:GetOrdinalString(number)
if number == 1 then
return "1st"
elseif number == 2 then
return "2nd"
elseif number == 3 then
return "3rd"
else
return number .. "th"
end
local ordinalStringLookup = {
[1] = "1st",
[2] = "2nd",
[3] = "3rd"
}

function AtlasUI:GetOrdinalString(number: number)
return ordinalStringLookup[number] or `${number}th`
end

function AtlasUI:ToPlural(singular: string)
local lastChar = string.sub(singular, -1)

if lastChar == "y" then
return string.sub(singular, 1, -2) .. "ies"
elseif lastChar == "s" then
return singular .. "es"
else
return singular .. "s"
end
end

0 comments on commit 4a8ab6e

Please sign in to comment.