LocalizePercentage (open)

Format a fractional value as percentage

Syntax

LOADLIB "wh::util/localization.whlib";

STRING FUNCTION LocalizePercentage(FLOAT value, INTEGER decimals, BOOLEAN grouping, STRING locale)

Parameters

FLOAT value

The value to format, 1 = 100%

INTEGER decimals

The number of decimals to display (the value will be rounded to the number of decimals)

BOOLEAN grouping

If the digits should be grouped using a thousand separator

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 = "25%"
STRING example1 := LocalizePercentage(.2468, 0, TRUE, "en");

// example2 = "24,68%"
STRING example2 := LocalizePercentage(2468, 2, TRUE, "nl");