LocalizeNumber (open)
Format a numerical value
Syntax
LOADLIB "wh::util/localization.whlib";
STRING FUNCTION LocalizeNumber(VARIANT value, INTEGER decimals, BOOLEAN grouping, BOOLEAN round, STRING locale)Parameters
VARIANT valueThe value to format, an INTEGER, INTEGER64, MONEY or FLOAT
INTEGER decimalsWhen rounding, the maximum number of decimals to show, otherwise the minimum number of decimals to show
BOOLEAN groupingIf the digits should be grouped using a thousand separator
BOOLEAN roundIf the value should be rounded to the number of decimals
STRING localeThe language or locale to use (e.g. 'en', 'en-GB', 'nl' or 'zh-Hans-CN')
Return value
STRINGThe formatted value
Examples
// example1 = "12,345.68"
STRING example1 := LocalizeNumber(12345.6789, 2, TRUE, TRUE, "en");
// example2 = "12.345,6789"
STRING example2 := LocalizeNumber(12345.6789, 0, TRUE, FALSE, "nl");
// example3 = "123.456.789,0000000000"
STRING example3 := LocalizeNumber(123456789, 10, TRUE, FALSE, "nl");