Skip to content

Commit

Permalink
Fixed game always loading in English after page refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-ed-raffalli committed Feb 2, 2018
1 parent d8b2b98 commit c1d7e26
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/containers/LocalizedRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ class LocalizedRoute extends Component {

setLocale(locale) {
if (locale && locale !== this.state.currentLocale && isLocaleSupported(locale)) {
this.setState(() => ({currentLocale: locale}));
this.props.setLocale(locale);
this.props.setLocale(locale)
.then(() => {
// only set the locale after it is loaded
// fix for game loading in en after page refresh
this.setState(() => ({currentLocale: locale}));
});
}
}

Expand Down Expand Up @@ -86,13 +90,12 @@ const mapDispatchToProps = dispatch => ({
initializeLocalization: () => {
dispatch(initialize(supportedGameLocales));
},
setLocale: (locale) => {
setLocale: locale =>
getTranslation(locale)
.then(translations => {
dispatch(addTranslationForLanguage(translations, locale));
dispatch(setActiveLanguage(locale));
});
}
})
});

export default connect(
Expand Down

0 comments on commit c1d7e26

Please sign in to comment.