mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
cb356a5db6
* feat(i18n): expand fallback system * rebase * apply feedback * better changeset * update tests too * apply feedback * Update .changeset/blue-pens-divide.md Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * update docs * nitpick * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/blue-pens-divide.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/blue-pens-divide.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * fix regression --------- Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
1.2 KiB
1.2 KiB
astro |
---|
minor |
Adds a new option fallbackType
to i18n.routing
configuration that allows you to control how fallback pages are handled.
When i18n.fallback
is configured, this new routing option controls whether to redirect to the fallback page, or to rewrite the fallback page's content in place.
The "redirect"
option is the default value and matches the current behavior of the existing fallback system.
The option "rewrite"
uses the new rewriting system to create fallback pages that render content on the original, requested URL without a browser refresh.
For example, the following configuration will generate a page /fr/index.html
that will contain the same HTML rendered by the page /en/index.html
when src/pages/fr/index.astro
does not exist.
// astro.config.mjs
export default defineConfig({
i18n: {
locals: ["en", "fr"],
defaultLocale: "en",
routing: {
prefixDefaultLocale: true,
fallbackType: "rewrite"
},
fallback: {
fr: "en"
},
}
})