Skip to content
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

feat: Always redirect to language that was saved in cookie #283

Merged
merged 1 commit into from
May 5, 2019
Merged

feat: Always redirect to language that was saved in cookie #283

merged 1 commit into from
May 5, 2019

Conversation

rchl
Copy link
Collaborator

@rchl rchl commented Apr 28, 2019

Make sure that after first visit, when we detect browser language and
store locale cookie, we reuse that cookie and re-set language during
navigation. Before this change, even with alwaysRedirect enabled, we
have only redirected on first visit and on next visits user got default
language again.

Changes:

  • Don't base ability to set client-side cookies on the isSpa flag.
    That flag signified whether app was in 'spa' mode (another possible
    mode is 'universal') and it only allowed setting client-side cookies
    in that mode. That's wrong as it should also be possible to set
    client-side cookies when running on client side in 'universal' mode.
    Use process.client and process.server instead, which are more
    appropriate flags to check for that purpose.
  • Expose setLocaleCookie on app.i18n (this.$i18n in components)
    as we need to be able to call it manually after changing locale
    in custom language selector.

Make sure that after first visit, when we detect browser language and
store locale cookie, we reuse that cookie and re-set language during
navigation. Before this change, even with `alwaysRedirect` enabled, we
have only redirected on first visit and on next visits user got default
language again.

Changes:
  - Don't base ability to set client-side cookies on the `isSpa` flag.
    That flag signified whether app was in 'spa' mode (another possible
    mode is 'universal') and it only allowed setting client-side cookies
    in that mode. That's wrong as it should also be possible to set
    client-side cookies when running on client side in 'universal' mode.
    Use `process.client` and `process.server` instead, which are more
    appropriate flags to check for that purpose.
  - Expose setLocaleCookie on `app.i18n` (`this.$i18n` in components)
    as we need to be able to call it manually after changing locale
    in custom language selector.
@codecov
Copy link

codecov bot commented Apr 28, 2019

Codecov Report

Merging #283 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #283   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines           4      4           
=====================================
  Hits            4      4

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a1de13...eaad725. Read the comment docs.

@paulgv paulgv changed the title Always redirect to browser's language that was saved in cookie feat: Always redirect to language that was saved in cookie May 5, 2019
@paulgv paulgv merged commit dc66895 into nuxt-modules:master May 5, 2019
@paulgv
Copy link
Collaborator

paulgv commented May 5, 2019

Thanks @rchl !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants