Skip to content

Instantly share code, notes, and snippets.

@ratbeard
Created January 28, 2019 22:13
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 ratbeard/b5fcd153a26a5ce89ded89a487f5fa74 to your computer and use it in GitHub Desktop.
Save ratbeard/b5fcd153a26a5ce89ded89a487f5fa74 to your computer and use it in GitHub Desktop.
// Export a helper component that allows for easy translations in views w/o
// needing to use the context directly. Only handles simple key lookup at the
// moment.
function Translate({ id }: {
id: keyof T
}) {
return (
<i18nContext.Consumer>
{
({ translate }) => translate(id)
}
</i18nContext.Consumer>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment