mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
b4b851f5a4
* feat(i18n): refined locales * feat: support granular locales inside the virtual module * feat: expose new function to retrieve the path by locale * chore: update fallback logic * chore: fix other broken cases inside source code * chore: add new test cases * maybe fix the type for codegen * changelog * Apply suggestions from code review Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> * chore: apply suggestions * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * fix: merge --------- Co-authored-by: Happydev <81974850+MoustaphaDev@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
26 lines
639 B
Markdown
26 lines
639 B
Markdown
---
|
|
'astro': minor
|
|
---
|
|
|
|
Adds a new way to configure the `i18n.locales` array.
|
|
|
|
Developers can now assign a custom URL path prefix that can span multiple language codes:
|
|
|
|
```js
|
|
// astro.config.mjs
|
|
export default defineConfig({
|
|
experimental: {
|
|
i18n: {
|
|
defaultLocale: "english",
|
|
locales: [
|
|
"de",
|
|
{ path: "english", codes: ["en", "en-US"]},
|
|
"fr",
|
|
],
|
|
routingStrategy: "prefix-always"
|
|
}
|
|
}
|
|
})
|
|
```
|
|
|
|
With the above configuration, the URL prefix of the default locale will be `/english/`. When computing `Astro.preferredLocale`, Astro will use the `codes`.
|