Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created May 4, 2022 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverJAsh/9143e5f03551c0548a8c575f5db39c57 to your computer and use it in GitHub Desktop.
Save OliverJAsh/9143e5f03551c0548a8c575f5db39c57 to your computer and use it in GitHub Desktop.
`intlc` example

Given this JSON + ICU Message:

{
  "uploaded": {
    "message": "Your <photoLink>photo</photoLink> has been uploaded.",
    "backend": "tsx"
  }
}

intlc outputs:

import { ReactElement } from 'react'
export const uploaded: (x: { photoLink: (x: ReactElement) => ReactElement }) => ReactElement = x => <>Your {x.photoLink(<>photo</>)} has been uploaded.</>

Usage:

import * as t from './lang';

export const App = () => (
  <div>
    {t.uploaded({
      photoLink: (child) => <a href="/photos/abcdef">{child}</a>,
    })}
  </div>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment