Skip to content

Fix Astro i18n config default locale issue#3288

Merged
delucis merged 1 commit intowithastro:mainfrom
HiDeoo:hd-fix-astro-i18n-default-locale
Jul 11, 2025
Merged

Fix Astro i18n config default locale issue#3288
delucis merged 1 commit intowithastro:mainfrom
HiDeoo:hd-fix-astro-i18n-default-locale

Conversation

@HiDeoo
Copy link
Copy Markdown
Member

@HiDeoo HiDeoo commented Jul 11, 2025

Description

This PR fixes an issue where Starlight can generate an invalid Astro i18n configuration.

When using custom locale paths, the default locale should match one of these paths. The current version uses the lang property of the defaultLocale configuration first, which would be fine in most cases, but for multilingual sites without a root locale and a default language that includes a regional subtag (e.g., zh-CN), this would not match the custom locale path (e.g. zh-CN instead of zh-cn).

We actually had tests checking the default locale of the generated Astro i18n configuration for similar cases but they were actually asserting the wrong value. I think this is something I missed at the time of the original implementation, altho I've added a todo for myself to make it either more obvious in the Astro Docs or maybe showcase that in the existing example, e.g. not using en as the default locale which does not use a custom locale path.

@netlify
Copy link
Copy Markdown

netlify bot commented Jul 11, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit fe21d5f
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/687115e30c5ba00008a724c1
😎 Deploy Preview https://deploy-preview-3288--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Jul 11, 2025
Copy link
Copy Markdown
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following up on this one @HiDeoo!

@delucis delucis added 🌟 patch Change that triggers a patch release ✅ approved Pull requests that have been approved and are ready to merge when next cutting a release labels Jul 11, 2025
@delucis delucis merged commit 131371e into withastro:main Jul 11, 2025
16 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jul 11, 2025
HiDeoo added a commit to shubham-padia/starlight that referenced this pull request Jul 15, 2025
* main: (26 commits)
  [ci] release (withastro#3296)
  Fix slug override with `/` value (withastro#3293)
  i18n(fr): update `guides/i18n.mdx` (withastro#3294)
  i18n(ko-KR): update `i18n.mdx` (withastro#3292)
  [ci] release (withastro#3286)
  Revert withastro#3281 (withastro#3291)
  i18n(de): update `guides/i18n.mdx` (withastro#3289)
  Fix Astro i18n config default locale issue (withastro#3288)
  docs: fix `t.exists()` documentation + example (withastro#3287)
  Make targeting sidebar links with CSS a little easier (withastro#3281)
  i18n(fr): update `resources/plugins.mdx` (withastro#3284)
  Extract main padding to CSS custom property  (withastro#3282)
  i18n(de): update plugins translation (withastro#3285)
  i18n(ko-KR): update `plugins.mdx` (withastro#3283)
  Add link to the codeblock-fullscreen plugin (withastro#3279)
  Fix TabItem typo in zh-cn authoring-content.mdx (withastro#3268) (withastro#3269)
  [ci] format
  i18n(ru): update translations (withastro#3270)
  Update `sharp` in docs & examples to latest (withastro#3261)
  Add missing danish UI translations (withastro#3252)
  ...
Yoxnear pushed a commit to Yoxnear/starlight-custom that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✅ approved Pull requests that have been approved and are ready to merge when next cutting a release 🌟 core Changes to Starlight’s main package 🌟 patch Change that triggers a patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[i18n config bug] Default locale not work for zh-CN

2 participants