This project uses ICU message format.
Formatted arguments are the preferred way of formatting. Custom formatting functions are allowed if the output is not part of the message (i.e. non translated value embeded directly in the markup) or if required formatting cannot be achieved using ICU format.
Common number formatting options (in concise syntax) and their mapping to Intl.NumberFormat properties (used for custom formatting functions):
minimumIntegerDigits: 1
->0
(integer-width)minimumFractionDigits: 0
,maximumFractionDigits: 0
->.
(equivalent to precision-integer )minimumFractionDigits: 1
,maximumFractionDigits: 1
->.0
(fraction-precision)useGrouping: false
->,_
(group-off)style: 'percent'
->%
(percent unit)
Given the following message:
dashboardUtilizationCardAvailableOfPercent: {
id: 'dashboard.utilizationCardAvailableOfPercent',
defaultMessage: 'of {percent, number, :: scale/0.01 % . 0 ,_ }',
description: 'part of utilization card\'s summary',
}
when we call msg.dashboardUtilizationCardAvailableOfPercent({ percent: 1234.5 })
, using en-US
locales, the output will be:
of 1235%
Full reference is available here.