Locales and formatting
Documents are formatted for the reader. Send a locale with each render, and the three
formatting filters follow it.
Choosing the locale
Section titled “Choosing the locale”The locale is a BCP 47 tag: en-US, pt-BR,
de-DE, ja-JP, ar-EG. The first of these that is set wins:
- the
localeof the render request, - the
localeof the saved template, - the default locale of your account (in Settings).
An invalid tag is a 400.
Filters
Section titled “Filters”currency
Section titled “currency”{{ total | currency(code="EUR") }}The amount is a number or a numeric string; use a string ("1234.50") to avoid floating
point surprises. The code is an ISO 4217 currency code. Amounts are rounded to the
currency’s own digits: two for most, none for yen, three for the Kuwaiti dinar.
| Locale | 1234.5 as USD / BRL / EUR |
|---|---|
en-US |
$1,234.50 |
pt-BR |
R$ 1.234,50 (BRL) |
de-DE |
1.234,50 € (EUR) |
number
Section titled “number”{{ qty | number }}{{ ratio | number(digits=2) }}Groups digits and uses the locale’s decimal separator. digits rounds and pads to exactly
that many decimals.
{{ issued | date(style="long") }}The value is an ISO date (2024-03-15) or a full timestamp (2024-03-15T10:00:00Z); only
the date part is used. style is short, medium (the default) or long.
| Locale | long |
|---|---|
en-US |
March 15, 2024 |
pt-BR |
15 de março de 2024 |
Overriding the locale in one place
Section titled “Overriding the locale in one place”Every filter accepts locale=, for a figure that must read the same in every render:
{{ total | currency(code="USD", locale="en-US") }}Scripts and fonts
Section titled “Scripts and fonts”Right-to-left scripts such as Arabic and Hebrew, and scripts such as Devanagari and Thai, are shaped correctly. Make sure a font that covers the script is available; see Fonts.