Skip to content

Commit

Permalink
fix: issue with locale not being updated when cookie not stored
Browse files Browse the repository at this point in the history
On initial opening of the site, if cookie with stored locale was not
saved yet, we failed to switching locale to follow the route we
navigated too.

Caused by logic that didn't set or update locale cookie when current
locale matched detected locale.
  • Loading branch information
rchl committed Aug 31, 2019
1 parent 14ceeb3 commit 999ac4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/templates/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ middleware['i18n'] = async (context) => {
if (redirectToLocale !== app.i18n.locale) {
// We switch the locale before redirect to prevent loops
await app.i18n.setLocale(redirectToLocale)
} else if (useCookie && !getLocaleCookie()) {
app.i18n.setLocaleCookie(redirectToLocale)
}
} else if (useCookie && !getLocaleCookie()) {
app.i18n.setLocaleCookie(redirectToLocale)
}

return
Expand Down

0 comments on commit 999ac4b

Please sign in to comment.