Skip to content

Commit

Permalink
Merge branch 'main' into aside-code
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis authored Jul 10, 2024
2 parents 7000d14 + 359a642 commit 4455f1f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-bananas-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Fixes an i18n configuration issue for multilingual sites when using Astro’s `i18n` config with `prefixDefaultLocale` set to `false`.
5 changes: 5 additions & 0 deletions docs/src/content/docs/resources/community-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Explore community-produced content maintained by Starlight users:
title="Adding Structured Data to Starlight Pages"
description="Learn how to build dynamic JSON-LD structured data for your documentation pages."
/>
<LinkCard
href="https://starlight-examples.netlify.app/"
title="Starlight Examples"
description="A collection of StackBlitz embeds demonstrating practical ways of doing stuff in Starlight documentation sites."
/>
</CardGrid>

## Video Content
Expand Down
4 changes: 2 additions & 2 deletions packages/starlight/__tests__/basics/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('processI18nConfig', () => {
locales: ['en', { codes: ['fr'], path: 'french' }],
},
expected: {
defaultLocale: { label: 'English', lang: 'en', dir: 'ltr', locale: 'en' },
defaultLocale: { label: 'English', lang: 'en', dir: 'ltr', locale: undefined },
locales: {
root: { label: 'English', lang: 'en', dir: 'ltr' },
french: { label: 'Français', lang: 'fr', dir: 'ltr' },
Expand All @@ -180,7 +180,7 @@ describe('processI18nConfig', () => {
routing: { prefixDefaultLocale: false },
},
expected: {
defaultLocale: { label: 'فارسی', lang: 'fa', dir: 'rtl', locale: 'fa' },
defaultLocale: { label: 'فارسی', lang: 'fa', dir: 'rtl', locale: undefined },
locales: {
root: { label: 'فارسی', lang: 'fa', dir: 'rtl' },
de: { label: 'Deutsch', lang: 'de', dir: 'ltr' },
Expand Down
11 changes: 6 additions & 5 deletions packages/starlight/utils/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ function getStarlightI18nConfig(
locales,
defaultLocale: {
...inferStarlightLocaleFromAstroLocale(defaultAstroLocale),
locale: isMonolingualWithRootLocale
? undefined
: isAstroLocaleExtendedConfig(defaultAstroLocale)
? defaultAstroLocale.codes[0]
: defaultAstroLocale,
locale:
isMonolingualWithRootLocale || (isMultilingual && !prefixDefaultLocale)
? undefined
: isAstroLocaleExtendedConfig(defaultAstroLocale)
? defaultAstroLocale.codes[0]
: defaultAstroLocale,
},
};
}
Expand Down

0 comments on commit 4455f1f

Please sign in to comment.