import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import { IntlProvider } from 'react-intl';
import { updateLocale } from '../actions/intlActions';

class LocaleProvider extends Component {
  componentDidMount() {
    let lang = this.context.store.getState().intl.locale || navigator.language;
    this.props
      .dispatch(updateLocale(lang))
      .then(() => {
        console.log('load locale (automatically) ok');
      }, (err) => {
        alert('load locale (automatically) fail', err);
      });
  }

  render() {
    const { intl, children } = this.props;
    return (
      <IntlProvider locale={intl.locale} messages={intl.messages}>
        {children}
      </IntlProvider>
    );
  }
};

LocaleProvider.contextTypes = {
  store: PropTypes.object.isRequired,
};

export default connect((state) => state)(LocaleProvider);

@@ -12,19 +12,8 @@
 t, %7B
- PropTypes,
  Com
@@ -35,16 +35,16 @@
 react';%0A
+
 import %7B
@@ -250,45 +250,56 @@
 let 
-lang = this.context.store.getState().
+%7B dispatch, intl %7D = this.props;%0A    let lang = 
 intl
@@ -333,30 +333,13 @@
 ge;%0A
-    this.props
 %0A    
-  .
 disp
@@ -581,24 +581,25 @@
 this.props;%0A
+%0A
     return (
@@ -726,82 +726,8 @@
 %7D;%0A%0A
-LocaleProvider.contextTypes = %7B%0A  store: PropTypes.object.isRequired,%0A%7D;%0A%0A
 expo
@@ -756,21 +756,41 @@
 ate) =%3E 
-state
+(%7B%0A  intl: state.intl,%0A%7D)
 )(Locale

Improve component LocaleProvider