* i18n(domains): validation and updated logic (#9099) * feat(i18n): domain with lookup table (#9112) * chore: add changelog, fix types and enable experimental support in node/vercel * rebase and update lock file * chore: fix failing test * Apply suggestions from code review Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Matthew Phillips <matthew@skypack.dev> * Update .changeset/tidy-carrots-jump.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * wip * chore: rebase, conflicts and tests * update lock file * chore: correct configuration * chore: correct configuration * fix: regressions * chore: fix conflicts and add more tests * chore: add more validation * chore: more tests and add more restrictions * fix changeset * change and revert adapters * add another restriction * lock file update * 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: Bjorn Lu <bjornlu.dev@gmail.com> * wat * fix syntax error * fix config example * Fix for #9673 (#9680) * Fix for #9673 * 🦋 add changeset file * Update breezy-plants-smoke.md Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> * ⚡️ simplified normalizeConfigPath --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> * Fix env var replacement for export const prerender (#9807) * feat(alpinejs): allow customizing the Alpine instance (#9751) * feat(alpinejs): allows customzing the Alpine instance * chore: add e2e tests * fix: rename script * Update index.ts * fix: lockfile * [ci] format * chore: use correct lock file * chore: rebase * fix regressions in tests * fix regressions in tests * fix build * add description * fix missing types * chore: fix tests, again :D * eslint * Update packages/astro/src/@types/astro.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * chore: address feedback * chore: fix regressions * chore: refactor naming * Update packages/astro/src/core/app/index.ts Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * chore: address feedback * update lock file * chore: infer routing from options, not strategy * merge from main * merge from main * Experimental support in vercel adapter * 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> * Update .changeset/tidy-carrots-jump.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * better changesets * Updates both experimental.i18nDomains and i18ndomains for experimental strategy * fix link syntax * consistent tabs/spaces * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * apply suggestion --------- Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Matthew Phillips <matthew@skypack.dev> Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Lou Cyx <git@lou.cx> Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Florian Lefebvre <ematipico@users.noreply.github.com> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
2.1 KiB
astro |
---|
minor |
Adds experimental support for a new i18n domain routing option ("domains"
) that allows you to configure different domains for individual locales in entirely server-rendered projects.
To enable this in your project, first configure your server
-rendered project's i18n routing with your preferences if you have not already done so. Then, set the experimental.i18nDomains
flag to true
and add i18n.domains
to map any of your supported locales
to custom URLs:
//astro.config.mjs"
import { defineConfig } from "astro/config"
export default defineConfig({
site: "https://example.com",
output: "server", // required, with no prerendered pages
adapter: node({
mode: 'standalone',
}),
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr", "ja"],
routing: {
prefixDefaultLocale: false
},
domains: {
fr: "https://fr.example.com",
es: "https://example.es"
}
},
experimental: {
i18nDomains: true
}
})
With "domains"
configured, the URLs emitted by getAbsoluteLocaleUrl()
and getAbsoluteLocaleUrlList()
will use the options set in i18n.domains
.
import { getAbsoluteLocaleUrl } from "astro:i18n";
getAbsoluteLocaleUrl("en", "about"); // will return "https://example.com/about"
getAbsoluteLocaleUrl("fr", "about"); // will return "https://fr.example.com/about"
getAbsoluteLocaleUrl("es", "about"); // will return "https://example.es/about"
getAbsoluteLocaleUrl("ja", "about"); // will return "https://example.com/ja/about"
Similarly, your localized files will create routes at corresponding URLs:
- The file
/en/about.astro
will be reachable at the URLhttps://example.com/about
. - The file
/fr/about.astro
will be reachable at the URLhttps://fr.example.com/about
. - The file
/es/about.astro
will be reachable at the URLhttps://example.es/about
. - The file
/ja/about.astro
will be reachable at the URLhttps://example.com/ja/about
.
See our Internationalization Guide for more details and limitations on this experimental routing feature.