Open biroplane opened 3 years ago
Hi @biroplane, force redirect isn't currently implemented. I guess it can be added as a new feature.
What you mean is having an option to turn URL localization "always on", right? In such a case you wouldn't be able to access http://your-website.com/ at all, but it would always redirect you to some language, in your case http://your-website.com/it/.
Btw, defaultLanguage
tells the app which language to use, in case it can't detect it from URL, last browsing session, or browser's preferences. It doesn't have any effect on URL localization right now.
as far as i noticed. it just need to set defaultLocale
to empty String and it does the job 👍
Interestingly, this can work for you, but it's not intentional and will fail eventually, with bunch of errors in the console along the way. Keep in mind that defaultLanguage
is required parameter in order for the Vue Language Router to work properly.
If you don't specify the language in the path, the Vue Language Router will try to get the previously used language from local storage, where it is stored as VueAppLanguage
. If it doesn't find it there, it tries to get preferred language from the browser. Tha last resort is using defaultLanguage
, which should always be available in your app.
When determining language, if a preferred language is found, but your app doesn't support it, it cannot be used - then the defaultLanguage
comes to play again.
What's likely happening in your case is that when the app obtains preferred language, it coincides with one of the translations you have in the app. Try doing this though:
VueAppLanguage
from local storage.It will fail horribly. Keep using defaultLanguage
😉
Force redirect should be added as a new feature.
i've just solved with a defaultLocale
set to an empty string. it does the trick ;)
can you give an example ?
defaultLanguage:''
nothing more than this...
I'm using this amazing plugin, but i can't figure out how to force
/
to go to/it/
path if none provided...thanks.