Reputation: 1021
I want to use an i18n basepath on Routify.
In other words, my URL is like this: www.example.com/about-us/
And I want to change it to this: www.example.com/[CURRENT_LANGUAGE]/about-us/
I've followed the example provided on the official website but it didn't work for me. When I add the /ru/
or /en/
prefix it works. But when I change the URL by clicking href
it removes the prefix but goes to the desired URL. I need to have the prefix in the new URL as well.
I think I need to change my href
s to adopt the new basepath logic. But not sure how to do it. How can I solve this issue? Any help is very much appreciated.
My build info: Svelte, Snowpack, Routify, Svelte-i18n.
GitHub repo: Click here
Upvotes: 0
Views: 371
Reputation: 1226
I tried copy pasting your App.svelte
to the starter template, but it works as expected. The language was retained when navigating.
If you're trying to change the active language, you have to
lang
value in your App.svelte
orwindow.location.href = '/en/some/page'
If you're using plain href
, you need to include $url
. Ie. <a href={$url('/about')>about</a>
or <a href="/about" use:$url>about</a>
. Otherwise, your URLs won't be rewritten. https://routify.dev/docs/helpers#url
Upvotes: 1