Open Foxandxss opened 1 year ago
I found myself in exactly the same spot. Any news on the matter?
found my solution..
use redirect experimental where release in astro 2.6.
redirects: {
"/es/solutions/[slug]": "/es/soluciones/[slug]",
"/soluciones/[slug]": "/solutions/[slug]",
}
You need to pass the full url to be localized, example:
mywebsite.com/[category]/[id] <- this is my url with dynamic paths.
const url = `items/${category}/${id}`
<a href="${localizePath(url)}">Localized link</a>
Describe the bug
localizePath is not able to localize urls with a dynamic path
To Reproduce
Say you have:
src/pages/solutions/[slug].astro
You will have routes like:
Then imagine I want to translate
solutions
to spanish, AKAsoluciones
I tried:
On the one hand I had to put the
index
part or it won't work but I tried to add[slug]
which generates the correct page. I can even go to:localhost:3000/es/soluciones/foo
and that will work, but if I tried something like:
it will generate:
So far I am doing:
That will generate:
Which works but breaks the LanguageSelector since it is not doing this trick.
localizePath should be able to localize a path with a dynamic path in it.
Context (please complete the following information):
astro-i18next
version: beta.21astro
version: 2.1.7