i18n gives unexpected paths in AstroJS 5 #12897
Labels
- P4: important
Violate documented behavior or significantly impacts performance (priority)
feat: i18n
Related to internalization (scope)
good first issue
Good for newcomers. If you need additional guidance, feel free to post in #dev on Discord
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I don't understand how i18n works in AstroJS 5: built-in functions return strange paths.
I want to use these settings for locales from my
src/siteConfig.ts
:i18n settings in
astro.config.mjs
:Now I want to test the website locally with language prefixes, for example:
My final goal is to use separate domain for each language version like Tripadvisor:
The problem: i18n functions
getRelativeLocaleUrlList()
andpathByLocale()
from package "astro:i18n" give me strange results.I use these functions in
src/layouts/Layout.astro
file. Layout receiveslocale
from Astro.params, for example,src/[locale]/index.astro
I request URL
http://localhost:4321/es/about
in browser and get lines in server console:The problem: why
relativeLocaleUrlList
andpathByLocale
are so strange?I expected smth like:
[ '/es/about', '/pt/about', '/en/about' ]
es/about
I tried to use
domains
inastro.config.mjs
since the beginning, but have failed for 3 days in row. So decided to undestand it first with locales in the path.What's the expected result?
All the paths will be relative to locale, but I get some mix of paths.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-dy6dtb63?file=src%2Flayouts%2FLayout.astro
Participation
The text was updated successfully, but these errors were encountered: