Skip to Content
ReferenceDialectsOverview

Dialects

A Dialect is a formatting language — its token grammar, the syntax family that separates tokens from literal text, and the canonical meaning of each token. It is tool-agnostic; a Library builds on one to model a concrete tool.

Built-in dialects are imported from rosetta-date/dialects:

import { ldml, moment, strftime } from 'rosetta-date/dialects'
DialectGrammarExampleLiteralsReference
momentMoment.js  token grammarDD/MM/YYYY[...]moment
ldmlUnicode UTS #35 / LDML  date field symbolsdd/MM/yyyy'...'ldml
strftimeC / POSIX strftime directives%d/%m/%Y%%strftime

Syntax families

A dialect’s syntax belongs to a tokenization family, which decides how tokens are told apart from literal text:

  • delimited (moment, ldml) — ASCII letters are token characters; literal text is set off by delimiters ([...], '...').
  • directive (strftime) — every token is introduced by a marker (%); all other text, letters included, is literal, and the marker is escaped by doubling it (%%).

The parser and renderer are generic over the family, so a new grammar is a new strategy rather than an engine change.

For the side-by-side token comparison across all dialects, see Token Mapping. Each dialect page below documents its own grammar, literals, aliases, and caveats.

To add a dialect, see the Contributing guide.

Last updated on