-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
SPA - default to browser language #103
Comments
This issue as been imported as question since it does not respect nuxt-i18n issue template. Only bug reports and feature requests stays open to reduce maintainers workload. |
Hi @mapeal2 ! |
This feature-request has been implemented by @paulgv in release v4.1.0. |
Hi @paulgv , That was my understanding, but couldn't make it work. I console logged "req" parameter in middleware.js and it's always undefined, and that's why the logic doesn't go into the browser detection block. Is there any circumstance that could make req be undefined? I'm missing something fundamental here... Thanks in advance. |
@mapeal2 sorry, I meant that I just implemented the change in the module, it did not work before but it should work if you upgrade to v4.1.0 :) |
Hi @paulgv , My fault, I had v4.0.2 and didn't realize that this functionality was available in v4.1.0. I've tested this now and I've detected what I think could be an issue, from my humble point of view. Given 2 locales ('en', 'fr'), default locale is 'en' and the preferred browser language is 'fr', with the 'prefix_except_default' option, the steps to reproduce it would be:
I would expect that, when opening the home page again, the application would be redirected to '/fr' instead of staying in '/'. Please confirm this is expected behaviour, if you'd be so kind. Regards. |
Hi @paulgv , Just to clarify what I'm looking for, I created a plugin to implement my expected behaviour. First, I set detectBrowserLanguage: false not to interfere with the new logic, and rather perform the actions in the mounted hook instead of doing it in the middleware, which could be less efficient (correct me if I'm wrong). Then I implemented this logic in the new plugin:
This way, whenever I enter '/', it always gets redirected to what is set in the cookie, except for the first time, in which the browser language is taken into account. Hope this clarifies my point of view. Thanks and regards. |
Hi @paulgv , Could then this be considered as an issue? Regards. |
Hi, Could you please take a look at the scenario I pointed out and let me know if this is something that could be incorporated/improved in future releases? Thanks in advance. |
Hi @mapeal2 sorry for the delay. [edit] Bug report opened: https://cmty.app/nuxt/nuxt-i18n/issues/c116 |
Hi,
Thanks for this awesome module, first of all. I'm developing a pure SPA with nuxt and I'm trying to implement nuxt-i18n for my project. Everything works well except for the fact that, when I enter the root URL for my application, the locale doesn't default to the current browser language. I've read the browser language detection in the doc, but I was wondering if this only applies to universal applications and whether this could be somehow adapted to pure SPAs.
Thanks in advance.
The text was updated successfully, but these errors were encountered: