Value on a Number
Using value
on a number is the proper way to format and output a number.
You have various options for formating:
-
by default it will format the number accordingly to the locale:
562407
will output 562,407 inen_US
, 562 407 infr_FR
(thanks tonumeral
lib) -
set
AS_IS
flag totrue
to avoid this formating -
set
TEXTUAL
flag totrue
to transform the number into text:#[+value(5500, {'TEXTUAL':true })]
will output five thousand five hundred -
set
ORDINAL_NUMBER
flag to true to to transform the number into an ordinal number:#[+value(21, {'ORDINAL_NUMBER':true })]
will output 21st -
set
ORDINAL_TEXTUAL
flag to true to to transform the number into an ordinal text:#[+value(20, {'ORDINAL_TEXTUAL':true })]
will output twentieth -
use
FORMAT
to set a format directly used bynumeral
. See numeral.js formats. This is very practical for currencies, %, etc. -
use
agree
forORDINAL_TEXTUAL
andTEXTUAL
(init_IT
,es_ES
andfr_FR
), for instance to have prima and not primo, or un/une (default agreement isM
) -
use
agree
forORDINAL_NUMBER
infr_FR
to manage 1er / 1re
numeral takes into account the locale: +value(104000, {'FORMAT': '0a$'}) will output 104k€ (yes, €!) when generating French.
|
Decimal numbers are supported using TEXTUAL
: 1.55
⇒ one point five five
in English. Same pattern for other languages.
Feature | en_US | fr_FR | de_DE | it_IT | es_ES |
---|---|---|---|---|---|
Default: standard number formatting |
yes |
yes |
yes |
yes |
yes |
|
yes |
yes |
yes |
yes |
yes |
|
yes |
yes |
yes |
yes |
yes |
|
yes |
yes (up to 100) |
yes (up to 1 million included) |
yes |
yes (up to 9999) |
|
yes |
yes |
yes |
yes |
yes |