Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(next): tweak i18n #9756

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/content/docs/en/guides/internationalization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ You can also choose to [add your own i18n logic in addition to or instead of Ast

## Configure i18n routing

Both a default language ([`defaultLocale`](/en/reference/configuration-reference/#i18ndefaultlocale)) and a list of all supported languages ([`locales`](/en/reference/configuration-reference/#i18nlocales)) must be specified in an `i18n` configuration object. Additionally, you can configure more specific routing and fallback behavior to match your desired URLs.
Both a list of all supported languages ([`locales`](/en/reference/configuration-reference/#i18nlocales)) and a default language ([`defaultLocale`](/en/reference/configuration-reference/#i18ndefaultlocale), must be one of the supported locales specified in `locales`) must be specified in an `i18n` configuration object. Additionally, you can configure more specific routing and fallback behavior to match your desired URLs.

```js title="astro.config.mjs"
import { defineConfig } from "astro/config"
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["es", "en", "pt-br"],
defaultLocale: "en",
}
})
```
Expand Down Expand Up @@ -106,8 +106,8 @@ This setting also determines where the page files for your default language must
import { defineConfig } from "astro/config"
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr"],
defaultLocale: "en",
routing: {
prefixDefaultLocale: false
}
Expand Down Expand Up @@ -140,8 +140,8 @@ This is the **default** value. Set this option when URLs in your default languag
import { defineConfig } from "astro/config"
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr"],
defaultLocale: "en",
routing: {
prefixDefaultLocale: true
}
Expand Down Expand Up @@ -190,8 +190,8 @@ You will be responsible for writing your own routing logic, or [executing Astro'
import { defineConfig } from "astro/config"
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr"],
defaultLocale: "en",
routing: "manual"
}
})
Expand Down Expand Up @@ -262,14 +262,14 @@ export default defineConfig({
mode: 'standalone',
}),
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr", "ja"],
defaultLocale: "en",
routing: {
prefixDefaultLocale: false
},
domains: {
fr: "https://fr.example.com",
es: "https://example.es"
fr: "https://fr.example.com",
es: "https://example.es"
}
}
})
Expand Down Expand Up @@ -305,8 +305,8 @@ For example, the configuration below sets `es` as the fallback locale for any mi
import { defineConfig } from "astro/config"
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr"],
defaultLocale: "en",
fallback: {
fr: "es"
},
Expand All @@ -325,16 +325,16 @@ Pass an object to the `locales` array with a `path` key to define a custom URL p

This is useful if you support multiple variations of a language (e.g. `"fr"`, `"fr-BR"`, and `"fr-CA"`) and you want to have all these variations mapped under the same URL `/fr/`, or even customize it entirely (e.g. `/french/`):

```js title="astro.config.mjs" del={5} ins={6-9}
```js title="astro.config.mjs" del={4} ins={5-8}
import { defineConfig } from "astro/config"
export default defineConfig({
i18n: {
defaultLocale: "en",
locales: ["es", "en", "fr"],
locales: ["es", "en", {
path: "french", // no slashes included
path: "french", // no slashes included
codes: ["fr", "fr-BR", "fr-CA"]
}],
defaultLocale: "en",
routing: {
prefixDefaultLocale: true
}
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/en/guides/upgrade-to/v4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ export default defineConfig({
experimental: {
devOverlay: true,
i18n: {
defaultLocale: "en",
locales: ["en", "fr", "pt-br", "es"],
defaultLocale: "en",
}
},
i18n: {
defaultLocale: "en",
locales: ["en", "fr", "pt-br", "es"],
defaultLocale: "en",
},
})
```
Expand Down
Loading