46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
' TODO:P2 Translations left:
|
|
' - Context menu
|
|
' - Search filters
|
|
' - Web app
|
|
' - Loading messages
|
|
|
|
import "pkg:/source/utils/MathUtils.bs"
|
|
|
|
namespace LocaleUtils
|
|
|
|
function GetPluralString(c as integer, zeroString as string, oneString as string, pluralString as string) as string
|
|
if c = 0
|
|
return Tr(zeroString)
|
|
else if c = 1
|
|
return Tr(oneString)
|
|
else
|
|
return Tr(pluralString).Replace("^n", c.toStr())
|
|
end if
|
|
end function
|
|
|
|
function GetFormattedPluralString(c as integer, zeroString as string, oneString as string, pluralString as string) as string
|
|
if c = 0
|
|
return Tr(zeroString)
|
|
else if c = 1
|
|
return Tr(oneString)
|
|
else
|
|
if c < 1000
|
|
return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr())
|
|
end if
|
|
c = c / 1000
|
|
if c < 1000
|
|
return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "K")
|
|
end if
|
|
|
|
c = c / 1000
|
|
if c < 1000
|
|
return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "M")
|
|
end if
|
|
|
|
c = c / 1000
|
|
return Tr(pluralString).Replace("^n", MathUtils.FormatFloat(c).toStr() + "B")
|
|
end if
|
|
end function
|
|
|
|
end namespace
|