rmdort / react-redux-multilingual

A simple and slim multi-lingual component for React with Redux without react-intl or react-i18n
41 stars 14 forks source link

Fix locale property of IntlProvider #12

Closed Jeremboo closed 6 years ago

Jeremboo commented 6 years ago

Hi, I encoutered the same error as the issue #9 ! Set the local property doesn't change the language by default.

It comes because local is overwrited by the default state.

So I fix it with this pull request !

rmdort commented 6 years ago

Hi, Thanks for the pull request, but this doesnt fix the issue. constructor will be called everytime a new locale is set, but it will always set locale to the this.props.locale. Locale switching wont work anymore.

To set the initial locale, you have to use initialState value in createStore

https://github.com/rmdort/react-redux-multilingual/blob/master/example/index.js#L11

Either this or use store.dispatch(setLocale('zh'))

Cheers Vinay

Jeremboo commented 6 years ago

Indeed, set the local value into the initalState in the createStore is most relevant !

It could be nice to update the README.md and the example folder with this method.

@rmdort have you the time to do that ?

rmdort commented 6 years ago

Its already in the Readme 👍

https://github.com/rmdort/react-redux-multilingual#setting-the-initial-locale

Jeremboo commented 6 years ago

locale="en" really troubled me... I'm apologize ! And thanks a lot !

Could you also update the Readme to remove the locale="en" and update (or remove) the Translate using context part please ? It could be troubling some guys like me haha.