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
Adds support for `Astro.currentLocale` and Astro’s i18n routing.
6
+
7
+
⚠️ **Potentially breaking change:** Starlight now configures Astro’s `i18n` option for you based on its `locales` config.
8
+
9
+
If you are currently using Astro’s `i18n` option as well as Starlight’s `locales` option, you will need to remove one of these.
10
+
In general we recommend using Starlight’s `locales`, but if you have a more advanced configuration you may choose to keep Astro’s `i18n` config instead.
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/i18n.mdx
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,8 @@ Starlight provides built-in support for multilingual sites, including routing, f
67
67
68
68
</Steps>
69
69
70
+
For more advanced i18n scenarios, Starlight also supports configuring internationalization using the [Astro’s `i18n` config](https://docs.astro.build/en/guides/internationalization/#configure-i18n-routing) option.
71
+
70
72
### Use a root locale
71
73
72
74
You can use a “root” locale to serve a language without any i18n prefix in its path. For example, if English is your root locale, an English page path would look like `/about` instead of `/en/about`.
@@ -272,3 +274,17 @@ export const collections = {
272
274
```
273
275
274
276
Learn more about content collection schemas in [“Defining a collection schema”](https://docs.astro.build/en/guides/content-collections/#defining-a-collection-schema) in the Astro docs.
277
+
278
+
## Accessing the current locale
279
+
280
+
You can use [`Astro.currentLocale`](https://docs.astro.build/en/reference/api-reference/#astrocurrentlocale) to read the current locale in `.astro` components.
281
+
282
+
The following example reads the current locale and uses it to generate a link to an about page in the current language:
0 commit comments