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 valueThe value to format, 1 = 100%
INTEGER decimalsThe number of decimals to display (the value will be rounded to the number of decimals)
BOOLEAN groupingIf the digits should be grouped using a thousand separator
STRING localeThe language or locale to use (e.g. 'en', 'en-GB', 'nl' or 'zh-Hans-CN')
Return value
STRINGThe formatted value
Examples
// example1 = "25%"
STRING example1 := LocalizePercentage(.2468, 0, TRUE, "en");
// example2 = "24,68%"
STRING example2 := LocalizePercentage(2468, 2, TRUE, "nl");