Request language from server

This commit is contained in:
Ildar Kamalov
2018-11-22 17:56:57 +03:00
parent 83544ab0f6
commit 63f20bc397
5 changed files with 81 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ import Footer from '../ui/Footer';
import Toasts from '../Toasts';
import Status from '../ui/Status';
import Update from '../ui/Update';
import i18n from '../../i18n';
class App extends Component {
componentDidMount() {
@@ -24,10 +25,32 @@ class App extends Component {
this.props.getVersion();
}
componentDidUpdate(prevProps) {
if (this.props.dashboard.language !== prevProps.dashboard.language) {
this.setLanguage();
}
}
handleStatusChange = () => {
this.props.enableDns();
};
setLanguage = () => {
const { processing, language } = this.props.dashboard;
if (!processing) {
if (!language) {
this.props.changeLanguage(i18n.language);
} else {
i18n.changeLanguage(language);
}
}
i18n.on('languageChanged', (lang) => {
this.props.changeLanguage(lang);
});
}
render() {
const { dashboard } = this.props;
const updateAvailable =
@@ -78,6 +101,7 @@ App.propTypes = {
isCoreRunning: PropTypes.bool,
error: PropTypes.string,
getVersion: PropTypes.func,
changeLanguage: PropTypes.func,
};
export default App;