2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova: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-11-29 14:08:24 +01:00
|
|
|
import { withCurrentUser } from 'meteor/nova:users';
|
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-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 (
|
|
|
|
<IntlProvider locale={this.getLocale()} messages={Telescope.strings[this.getLocale()]}>
|
|
|
|
{
|
2016-11-10 17:26:55 +09:00
|
|
|
this.props.loading ?
|
2016-11-27 19:12:54 +09:00
|
|
|
<Telescope.components.Loading /> :
|
|
|
|
<Telescope.components.Layout>{this.props.children}</Telescope.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 = {
|
2016-11-10 17:26:55 +09:00
|
|
|
loading: 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
|
|
|
|
2016-11-29 18:54:37 +09:00
|
|
|
Telescope.registerComponent('App', App, withCurrentUser);
|
2016-11-27 19:12:54 +09:00
|
|
|
|
|
|
|
export default App;
|