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 value

The value to format, an INTEGER, INTEGER64, MONEY or FLOAT

INTEGER decimals

When rounding, the maximum number of decimals to show, otherwise the minimum number of decimals to show

BOOLEAN grouping

If the digits should be grouped using a thousand separator

BOOLEAN round

If the value should be rounded to the number of decimals

STRING locale

The language or locale to use (e.g. 'en', 'en-GB', 'nl' or 'zh-Hans-CN')

Return value

STRING

The 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");