unsplash / intlc

Compile ICU messages into code. Supports TypeScript and JSX. No runtime.
MIT License
57 stars 3 forks source link

`boolean` fails to capture nested parameters #100

Closed OliverJAsh closed 2 years ago

OliverJAsh commented 2 years ago

Given:

{
  "userAddedAPhotoToTheirCollection": {
    "backend": "tsx",
    "message": "<user></user> added your photo to {hasCollection, boolean, true {one of their collections} false {<collectionEl></collectionEl>}}. ➕"
  }
}

Run:

$ intlc compile app/components/Notifications/components/Phrase/lang/en-US.translations.json -l es-ES
import { ReactElement } from 'react'
export const userAddedAPhotoToTheirCollection: (x: { hasCollection: boolean; user: (x: ReactElement) => ReactElement }) => ReactElement = x => <>{x.user(<></>)} added your photo to {(() => { switch (x.hasCollection) { case true: return <>one of their collections</>; case false: return <>{x.collectionEl(<></>)}</>; } })()}. ➕</>

Observe how x.collectionEl is not defined.

Note we do not have this problem for select.