Skip to content

Locales and formatting

Documents are formatted for the reader. Send a locale with each render, and the three formatting filters follow it.

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:

  1. the locale of the render request,
  2. the locale of the saved template,
  3. the default locale of your account (in Settings).

An invalid tag is a 400.

{{ 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)
{{ 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

Every filter accepts locale=, for a figure that must read the same in every render:

{{ total | currency(code="USD", locale="en-US") }}

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.