How to use the react-i18next.Trans.contextTypes function in react-i18next

To help you get started, we’ve selected a few react-i18next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github go-faast / faast-web / src / app / components / i18n / T.jsx View on Github external
block: PropTypes.bool,
    tag: PropTypes.string || PropTypes.func,
    ...Trans.propTypes,
    i18nKey: PropTypes.string.isRequired,
    translate: PropTypes.bool,
  }),
  defaultProps({
    block: false,
    tag: 'span',
    translate: true,
  }),
  mapProps(({ block, parent, tag, ...rest }) => ({
    parent: block ? 'div' : (parent || tag),
    ...rest,
  })),
  getContext(Trans.contextTypes)
)((props) => {
  const { i18nKey, children, translate, } = props
  if (!translate) {
    return children
  }
  if (!(/^[\w.:]+$/).test(i18nKey)) {
    console.error(`Invalid i18nKey '${i18nKey}' provided to T for: ${children}`)
    return null
  }
  return ()
})