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

Cannot access localePath in middleware #24

Closed
RomainLK opened this issue Feb 19, 2018 · 5 comments
Closed

Cannot access localePath in middleware #24

RomainLK opened this issue Feb 19, 2018 · 5 comments

Comments

@RomainLK
Copy link

RomainLK commented Feb 19, 2018

I'm making a middleware which redirects users to some pages depending on the store informations. However, I'm lacking localePath to localise the path for the redirect. I expected it to be available as context.app.localePath, but it's not.

More interestingly, it's available at context.app.i18n.vm.localePath but the this context is not correct. localePath is somehow bound to a component which has neither $router or $i18n resulting in an error in i18n.routing.plugin.js

For now I'm running out of idea. I suspect that it might be a problem with nuxt lifecycle between plugins / middleware but it's still obscure.

Versions:
nuxt: 1.3
nuxt-i18n: 2.2.4

This question is available on Nuxt.js community (#c16)
@dave2k2
Copy link

dave2k2 commented May 3, 2018

@RomainLK did you ever find a resolution to this? facing a similar issue using middleware to redirect based on a token existing within the store

@unr
Copy link

unr commented May 31, 2018

Still haven't found any resolution to this, :(

@unr
Copy link

unr commented May 31, 2018

Nevermind, actually found the answer to this looking at #25.

https://github.com/nuxt-community/nuxt-i18n/pull/25/files#diff-6aeb88ffa6a6d00ecc6e8f0487e8d069R66

You can access localePath via app.localePath, not app.i18n.localePath, like we're all expecting.

@mrleblanc101
Copy link
Contributor

Could this be corrected in the doc ? See: https://nuxt-community.github.io/nuxt-i18n/basic-usage.html#nuxt-link

@paulgv
Copy link
Collaborator

paulgv commented Apr 25, 2019

@mrleblanc101 done! Feel free to open PRs to help improve the doc, it can be done right in GitHub by clicking the Edit this page on GitHub link at the bottom of each documentation page.

kazupon pushed a commit that referenced this issue Nov 25, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
* refactor: merge tests

* refactor: merge tests (#24)
DarthGigi pushed a commit to DarthGigi/i18n that referenced this issue Apr 16, 2024
* refactor: merge tests

* refactor: merge tests (nuxt-modules#24)
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

No branches or pull requests

5 participants