-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the locale without reloading the app. #54
Comments
You could |
Actually, I figured it out a while back. For those who question, this is what I am doing in my redux logic: /**
* Logic
*/
export const initialiseLogic = createLogic({
type: INITIALISE,
latest: true,
process({ getState, action }, dispatch, done) {
const account = getState()['account'].account
let agentLocale = account ? account.locale : intl.determineLocale({
urlLocaleKey: "lang",
cookieLocaleKey: "lang"
})
if (Object.keys(locales).findIndex( v => v === agentLocale ) === -1) {
agentLocale = Locales["en-US"]
}
dispatch(setLocale(agentLocale))
done()
}
})
export const setLocaleLogic = createLogic({
type: SET_LOCALE,
latest: true,
process({ getState, action }, dispatch, done) {
const account = getState()['account'].account
account && account.locale !== action.payload.locale && dispatch(updateAccount({locale: action.payload.locale}))
intl.init({
currentLocale: action.payload.locale,
locales
}).then(() => {
dispatch(initialised())
done()
})
}
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to change the locale without forcing the entire app to reload? Setting the locale via the search parameter of the URL is causing the entire app to reload, which is conflicting with an update to the user's profile. It seems like this being a react solution, it should be reactive, but its current implementation imposes a bad experience on users, IMO.
The text was updated successfully, but these errors were encountered: