2017-03-23 16:27:59 +09:00
|
|
|
import { Components, registerComponent, getSetting, Strings } from 'meteor/vulcan:lib';
|
2016-03-17 18:08:03 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
2016-06-09 20:45:58 +09:00
|
|
|
import { IntlProvider, intlShape} from 'react-intl';
|
2016-12-21 12:04:43 +01:00
|
|
|
import withCurrentUser from '../containers/withCurrentUser.js';
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2016-12-12 15:10:53 +09:00
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
class App extends Component {
|
2016-03-24 18:17:35 +09:00
|
|
|
|
2016-06-09 17:42:20 +09:00
|
|
|
getLocale() {
|
2016-12-12 15:00:56 +09:00
|
|
|
return getSetting("locale", "en");
|
2016-06-09 17:42:20 +09:00
|
|
|
}
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
getChildContext() {
|
2016-06-09 17:42:20 +09:00
|
|
|
|
2016-12-12 15:10:53 +09:00
|
|
|
const messages = Strings[this.getLocale()] || {};
|
2016-06-09 20:45:58 +09:00
|
|
|
const intlProvider = new IntlProvider({locale: this.getLocale()}, messages);
|
|
|
|
|
2016-06-09 17:42:20 +09:00
|
|
|
const {intl} = intlProvider.getChildContext();
|
|
|
|
|
2016-03-24 18:17:35 +09:00
|
|
|
return {
|
2016-06-09 17:42:20 +09:00
|
|
|
intl: intl
|
2016-03-24 18:17:35 +09:00
|
|
|
};
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
2016-02-14 12:27:20 +09:00
|
|
|
|
|
|
|
render() {
|
2016-06-16 10:43:25 +09:00
|
|
|
return (
|
2016-12-12 15:10:53 +09:00
|
|
|
<IntlProvider locale={this.getLocale()} messages={Strings[this.getLocale()]}>
|
2017-05-09 10:14:10 +09:00
|
|
|
<Components.Layout>
|
|
|
|
{ this.props.currentUserLoading ? <Components.Loading /> : this.props.children }
|
|
|
|
</Components.Layout>
|
2016-06-16 10:43:25 +09:00
|
|
|
</IntlProvider>
|
|
|
|
)
|
2016-02-14 12:27:20 +09:00
|
|
|
}
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = {
|
2017-04-20 16:04:24 +09:00
|
|
|
currentUserLoading: React.PropTypes.bool,
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.childContextTypes = {
|
2016-11-03 14:39:27 +09:00
|
|
|
intl: intlShape,
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
2016-02-16 15:40:37 +09:00
|
|
|
|
2017-01-18 12:51:10 +01:00
|
|
|
App.displayName = 'App';
|
|
|
|
|
2016-12-21 12:04:43 +01:00
|
|
|
registerComponent('App', App, withCurrentUser);
|
2016-11-27 19:12:54 +09:00
|
|
|
|
2016-12-21 12:04:43 +01:00
|
|
|
export default App;
|