You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/02.guide/10.multi-domain-locales.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ How to set up multi domain locales:
9
9
- Configure the `locales` option as an array of objects:
10
10
- Each object has a `domains` key whose value is a array of the domains you'd like to use for that locale. Optionally include a port (if non-standard) and/or a protocol. If the protocol is not provided then an attempt will be made to auto-detect it but that might not work correctly in some cases like when the pages are statically generated.
11
11
- Optionally set for each object a `defaultForDomains` key whose value is a array of the default domains you'd like to use for that locale. Optionally include a port (if non-standard) and/or a protocol. If the protocol is not provided then an attempt will be made to auto-detect it but that might not work correctly in some cases like when the pages are statically generated.
12
+
- Optionally set `defaultLocale`. Each domain resolves its own unprefixed locale from `defaultForDomains`, this names the fallback for the cluster as a whole - see [`defaultLocale` and `x-default`](#defaultlocale-and-x-default).
12
13
- Optionally set `detectBrowserLanguage` to `false`{lang="ts"}. When enabled (which it is by default), a first visit can be redirected to the locale detected from the browser, within the current domain. Set to `false`{lang="ts"} if you want to ensure that visiting a given domain always shows the page in that domain's own locale.
@@ -213,3 +215,9 @@ Given the above configuration, following requests will be:
213
215
Locales served on other domains stay available in `locales` and in the locale switcher, `switchLocalePath` links to them on the domain that serves them. Browser language detection only applies locales served on the current domain, so a visitor whose browser or cookie locale isn't available there keeps that domain's own locale.
214
216
215
217
A request on a host that doesn't match any configured domain, such as a staging domain or a health check by IP, isn't restricted. Every locale is served there and `defaultLocale` is used as the unprefixed default, so it's worth setting even when every domain has its own default through `defaultForDomains`.
218
+
219
+
## `defaultLocale` and `x-default`
220
+
221
+
The domains are annotated as one cluster, each page links to its alternates on the other domains. A cluster has a single fallback for unmatched languages, so the `x-default` alternate is taken from `defaultLocale` rather than from the locale a domain happens to default to - otherwise every domain would name a different one.
222
+
223
+
`defaultLocale` is optional here, since each domain resolves its own unprefixed locale through `defaultForDomains`. Leaving it out means no `x-default` is annotated at all, which is allowed but drops a signal for visitors whose language matches none of your locales. A warning is logged when it isn't set.
0 commit comments