opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
22 stars 0 forks source link

Paraglide-SvelteKit: Translated Parameters #155

Open rbozan opened 2 weeks ago

rbozan commented 2 weeks ago

For example let's say that we have a route called /lesson/[:name] where [:name] is an ordinal number in the selected language, it means these exist:

/en/lesson/first , /en/lesson/second, /en/lesson/third /nl/lesson/eerste, /nl/lesson/tweede, /nl/lesson/derde

The problem is that when you are on the path /en/lesson/first it will incorrectly generate /nl/lesson/first as alternative links in the head tag. Could we somehow customize this so we can give the correct alternative links?

LorisSigrist commented 2 weeks ago

Translated Parameters like the ones you described are on our roadmap and will be added soon.

In the meantime you could disable alternate-link generation & add them manually so you get the result you want.

// src/lib/i18n.js

export const i18n = createI18n({
  seo: { noAlternateLinks: true }
})

For reference, this is the code paraglide-sveltekit currently uses to generate alternate links.

https://github.com/opral/monorepo/blob/main/inlang/source-code/paraglide/paraglide-sveltekit/src/runtime/AlternateLinks.svelte

rbozan commented 2 weeks ago

But can that be done on a per page basis?

LorisSigrist commented 2 weeks ago

Currently no, but you can do it from a layout