Hey! I have a few questions about Astro’s i18n setup (based on the official guide).
The docs show a structure like this:
src/
└─ pages/
├─ about.astro
├─ index.astro
├─ es/
│ ├─ about.astro
│ └─ index.astro
└─ pt-br/
├─ about.astro
└─ index.astro
- Do I really need a folder for each language?
If I have 20 languages plus a default one, does that mean 20 folders?
And does this mean I have to duplicate every page for every locale?
- I tried using a dynamic
[locale]folder instead:
src/
└─ pages/
├─ index.astro # docs say this file is always required
└─ [locale]/
├─ about.astro
└─ index.astro
And here’s my astro.config.mjs:
site: 'https://mysite.com',
output: 'server',
i18n: {
defaultLocale: 'en',
locales: ['en', 'es', 'fr'],
routing: {
prefixDefaultLocale: true,
},
},
integrations: [
sitemap({
i18n: {
defaultLocale: 'en',
locales: {
en: 'en',
es: 'es',
fr: 'fr',
},
},
}),
],
But on build I get:
[WARN] [@astrojs/sitemap] No pages found!
`sitemap-index.xml` not created.
It looks like the sitemap integration doesn’t detect the routes when using the [locale] folder. Is this expected, or am I missing something in the configuration?