I have a multilingual Vue (Nuxt) app. Based I'm setting the selected language / locale in the URL, e.g. http://www.example.net/sv-SE/somepage
.
The routes are registered with an optional iso code: /:iso_code([a-z]{2}-[A-Z]{2})?/somepage
. This all works as intented.
Now to my question: I have a language dropdown where the user can set the desired language. Is there any way to update the route param iso_code
above, without resorting to history.replaceState
?
I've tried the router API, without success. The URL isn't updated, i.e. if the URL is http://www.example.net/sv-SE/somepage
, sv-SE
isn't replaced with en-US
when running the code:
this.$router.replace({ path: this.$route.fullPath, params: { iso_code: 'en-US' } })