sveltekit-i18n / lib

Internationalization library built for SvelteKit.
MIT License
447 stars 28 forks source link

A way to show or hide defaultLocale path #134

Closed yazer79 closed 11 months ago

yazer79 commented 11 months ago

I need to show the defaultLocale path '/en/'.

I have seen the other post that some requested to remove the defaultLocale from path for "better SEO" and that their request was done. This is certainly better in some cases, but not all cases are alike. Some other cases might need the locale paths to be shown for example if they want to switch the "default" language or have a site with path '/en/' that is already indexed.

I tried to comment the replace function in hooks, but I didn't succeed.

Can it please be optional? It would be much versatile then and will suit all cases.

jarda-svoboda commented 11 months ago

Hi @yazer79! Have you seen this example? I think that’s what you are looking for.

yazer79 commented 11 months ago

Hi @jarda-svoboda .. Yes, I tried it and it works better for my case. The example docs were not clear about what it is about. It would be easier to see something like "Use this example if you are trying to get local routing for all language paths: i.e 'example.com/en/about', 'example.com/de/about'

There is also an important thing, the content links display the path only if used this way: <a href="/{$locale}/blog/{blog.id}">{blog.name}</a></li> this outputs page source: href="/en/blog/123" It would be better seo wise for lang hrefs to include the TLD like href="example.com/en/blog/123" Is this possible in our case? N.B: I am only testing on dev, not production yet

jarda-svoboda commented 11 months ago

Oh, so maybe you just need to combine these two examples? locale-router and locale-router-advanced