How to use the react-intl.IntlMixin.formatMessage function in react-intl

To help you get started, we’ve selected a few react-intl 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 iam4x / isomorphic-flux-boilerplate / app / utils / i18n-container.jsx View on Github external
i18n = (key, values) => {
    try {
      // Fake IntlMixin context with `messages`, `formats` and `locales`
      // into `this.props` and `this.context`
      const ctx = { ...IntlMixin, context: this.state, props: this.state }

      const messages = IntlMixin.getIntlMessage.call(ctx, key)
      return IntlMixin.formatMessage.call(ctx, messages, values)
    } catch (error) {
      debug('dev')(error)
      return `translation missing (${this.state.locales[0]}): ${key}`
    }
  }
github lxerxa / actionview-fe / app / utils / react-intl-wrapper.js View on Github external
export function getIntlMessage(key, values) {
  try {
    const messages = i18n.getIntlMessage.call(this, key);
    return i18n.formatMessage.call({ ...this, ...i18n }, messages, values);
  } catch (error) {
    debug('dev')(error);
    return `translation missing ${this.props.locale}: ${key}`;
  }
}