2017-03-23 16:27:59 +09:00
|
|
|
import { Components, registerComponent, getSetting, Strings } from 'meteor/vulcan:lib';
|
2017-05-19 14:42:43 -06:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-06-01 11:42:30 +09:00
|
|
|
import { IntlProvider, intlShape} from 'meteor/vulcan:i18n';
|
2016-12-21 12:04:43 +01:00
|
|
|
import withCurrentUser from '../containers/withCurrentUser.js';
|
2016-02-14 12:27:20 +09:00
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
class App extends PureComponent {
|
2016-03-24 18:17:35 +09:00
|
|
|
|
2016-06-09 17:42:20 +09:00
|
|
|
getLocale() {
|
2017-05-19 14:42:43 -06: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);
|
2017-05-19 14:42:43 -06: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-06-07 05:04:05 -07:00
|
|
|
<Components.Layout {...this.props} >
|
2017-05-09 10:14:10 +09:00
|
|
|
{ this.props.currentUserLoading ? <Components.Loading /> : this.props.children }
|
|
|
|
</Components.Layout>
|
2016-06-16 10:43:25 +09:00
|
|
|
</IntlProvider>
|
2017-05-19 14:42:43 -06:00
|
|
|
);
|
2016-02-14 12:27:20 +09:00
|
|
|
}
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = {
|
2017-05-23 08:42:28 -06:00
|
|
|
currentUserLoading: 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;
|