garrysmod-requests icon indicating copy to clipboard operation
garrysmod-requests copied to clipboard

International number formatting API

Open Lexicality opened this issue 9 months ago • 2 comments
trafficstars

Details

It'd be great to have a function like language.FormatNumber that returns the correctly formatted number for the user's currently selected language.

Example of different locale number styles:

mynumber = 123_456_789.012
// 123456789.012345
new Intl.NumberFormat("en-GB").format(mynumber)
// "123,456,789.012"
new Intl.NumberFormat("de-DE").format(mynumber)
// "123.456.789,012"
new Intl.NumberFormat("fr-FR").format(mynumber)
// "123 456 789,012"
new Intl.NumberFormat("en-IN").format(mynumber)
// "12,34,56,789.012" 

Lexicality avatar Feb 01 '25 17:02 Lexicality

Should be in LUA, so better make a Pool Request to the garrysmod repository

JarosLucky avatar Feb 05 '25 03:02 JarosLucky

Should be in LUA, so better make a Pool Request to the garrysmod repository

This is a standard feature of i18n libraries so I'd rather not go to the effort of making a very slow string manipulation mess myself if it could be a single FFI call instead.

Also Lua isn't an acronym, it's a proper noun.

Lexicality avatar Feb 05 '25 07:02 Lexicality