This is a reproduction example for the issue I'm facing with SvelteKit and Paraglide-JS.
npm install
npm run build && npm run preview
http://localhost:4173/
The language should change and the text and URL should be updated.
The language changes for a split of a second but then it reverts back to the previous language and doesn't change the URL.
It doesn't matter if you use the preferredLocale
as a strategy or not, the behavior is the same. (Just the initial language is different)
The reason for all of this are the urlPatterns
from the vite config. If you remove them, everything works as expected.
import { paraglideVitePlugin } from "@inlang/paraglide-js";
export default defineConfig({
plugins: [
// ...
paraglideVitePlugin({
// ...
urlPatterns: [
{
pattern: "/:path(.*)?",
localized: [
["en", "/:path(.*)?"],
["de", "/:path(.*)?"],
],
},
],
}),
],
// ...
});
If you leave them there, the bug occurs. I've use two examples from the docs.