How to use the react-intl.IntlMixin.getIntlMessage 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 iam4x / isomorphic-flux-boilerplate / app / components / protected.jsx View on Github external
import React, { Component, PropTypes } from 'react';
import { IntlMixin } from 'react-intl';

import requireAuth from 'components/shared/require-auth';

@requireAuth
class Protected extends Component {

  static propTypes = {
    flux: PropTypes.object.isRequired
  }

  i18n = IntlMixin.getIntlMessage

  componentWillMount() {
    const { flux } = this.props;
    flux.getActions('helmet')
      .update({ title: this.i18n('protected.page-title') });
  }

  render() {
    return (
      <div>
        <h1>Protected</h1>
        <p>secret mesaage</p>
      </div>
    );
  }
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}`;
  }
}