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-05-22 15:23:30 +09:00
|
|
|
import { AppComposer } from "meteor/nova:core";
|
2016-02-14 12:27:20 +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-06-09 20:45:58 +09:00
|
|
|
return Telescope.settings.get("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-06-09 20:45:58 +09:00
|
|
|
const messages = Telescope.strings[this.getLocale()] || {};
|
|
|
|
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-03-27 13:04:21 +09:00
|
|
|
currentUser: this.props.currentUser,
|
2016-06-14 22:36:54 +02:00
|
|
|
actions: this.props.actions,
|
2016-06-14 17:03:35 +09:00
|
|
|
events: this.props.events,
|
|
|
|
messages: this.props.messages,
|
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-09 17:42:20 +09:00
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
if (this.props.ready) {
|
2016-06-09 17:42:20 +09:00
|
|
|
return (
|
|
|
|
<IntlProvider locale={this.getLocale()} messages={Telescope.strings[this.getLocale()]}>
|
2016-06-11 16:36:18 +09:00
|
|
|
<Telescope.components.Layout currentUser={this.props.currentUser}>{this.props.children}</Telescope.components.Layout>
|
2016-06-09 17:42:20 +09:00
|
|
|
</IntlProvider>
|
|
|
|
)
|
2016-02-16 15:08:30 +09:00
|
|
|
} else {
|
2016-05-22 16:42:24 +09:00
|
|
|
return <Telescope.components.AppLoading />
|
2016-02-16 15:08:30 +09:00
|
|
|
}
|
2016-02-14 12:27:20 +09:00
|
|
|
}
|
|
|
|
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.propTypes = {
|
|
|
|
ready: React.PropTypes.bool,
|
|
|
|
currentUser: React.PropTypes.object,
|
2016-06-14 22:36:54 +02:00
|
|
|
actions: React.PropTypes.object,
|
|
|
|
events: React.PropTypes.object,
|
|
|
|
messages: React.PropTypes.object,
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
App.childContextTypes = {
|
|
|
|
currentUser: React.PropTypes.object,
|
2016-06-14 22:36:54 +02:00
|
|
|
actions: React.PropTypes.object,
|
2016-06-14 17:03:35 +09:00
|
|
|
events: React.PropTypes.object,
|
|
|
|
messages: React.PropTypes.object,
|
2016-06-09 17:42:20 +09:00
|
|
|
intl: intlShape
|
2016-03-27 13:04:21 +09:00
|
|
|
}
|
2016-02-16 15:40:37 +09:00
|
|
|
|
2016-03-27 16:32:29 +09:00
|
|
|
module.exports = AppComposer(App);
|
|
|
|
export default AppComposer(App);
|