-
Notifications
You must be signed in to change notification settings - Fork 3
ICU syntax
intlc supports most common ICU syntax with some optional extras.
Hello, world!
Anything not included in brace-denoted interpolations is parsed as plaintext. Escaping is supported as per the ICU 4.8+ spec.
{name}
String interpolations don't require an explicit type annotation.
{age, number}
❎ Number skeletons are not yet supported.
{today, date, medium}: {now, time, short}
A format is required. Valid values are short
, medium
, long
, and full
.
❎ Date and time skeletons are not yet supported.
A {day, select, Friday {great} Monday {less great} other {}} day
🌟 Unlike other implementations targeting TypeScript, intlc will output a string literal union if a wildcard (other
) is not provided.
{numStars, plural, one {# person likes} other {# people like}} intlc
Both plural
and selectordinal
, representing cardinal and ordinal pluralization respectively, are supported. The #
shorthand syntax to reference the same interpolated value is supported.
🌟 Unlike other implementations targeting TypeScript, intlc will output a number literal union if a wildcard (other
) is not provided. This is only supported and semantically reasonable with cardinal plural
.
Hello <bold>{name}</bold>
The above example compiles a little differently depending upon the targeted backend. With a ts
backend bold
will be string -> string
, whereas with a tsx
backend it will be ReactElement -> ReactElement
.
{isSubscribed, boolean, true {Manage} false {Subscribe}}
The boolean
type is in practice similar to select
with true
and false
cases, particularly in intlc where a wildcard is not required. Its addition is simply to avoid the need to cast boolean
to 'true' | 'false'
at call sites.