File tree Expand file tree Collapse file tree 4 files changed +13
-3
lines changed
i18n-non-root-single-locale Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @astrojs/starlight ' : patch
3
+ ---
4
+
5
+ Fixes a potential configuration issue for multilingual sites with a default language including a regional subtag.
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ describe('processI18nConfig', () => {
7
7
test ( 'returns the Astro i18n config for a monolingual site with a non-root single locale' , ( ) => {
8
8
const { astroI18nConfig, starlightConfig } = processI18nConfig ( config , undefined ) ;
9
9
10
- expect ( astroI18nConfig . defaultLocale ) . toBe ( 'fr-CA' ) ;
10
+ // The default locale should match its associated custom locale `path`.
11
+ expect ( astroI18nConfig . defaultLocale ) . toBe ( 'fr' ) ;
11
12
expect ( astroI18nConfig . locales ) . toMatchInlineSnapshot ( `
12
13
[
13
14
{
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ describe('processI18nConfig', () => {
7
7
test ( 'returns the Astro i18n config for a multilingual site with no root locale' , ( ) => {
8
8
const { astroI18nConfig, starlightConfig } = processI18nConfig ( config , undefined ) ;
9
9
10
- expect ( astroI18nConfig . defaultLocale ) . toBe ( 'en-US' ) ;
10
+ // The default locale should match its associated custom locale `path`.
11
+ expect ( astroI18nConfig . defaultLocale ) . toBe ( 'en' ) ;
11
12
expect ( astroI18nConfig . locales ) . toMatchInlineSnapshot ( `
12
13
[
13
14
{
Original file line number Diff line number Diff line change @@ -53,8 +53,11 @@ export function processI18nConfig(
53
53
/** Generate an Astro i18n configuration based on a Starlight configuration. */
54
54
function getAstroI18nConfig ( config : StarlightConfig ) : NonNullable < AstroConfig [ 'i18n' ] > {
55
55
return {
56
+ // When using custom locale `path`s, the default locale must match one of these paths.
57
+ // In Starlight, this matches the `locale` property if defined, and we fallback to the `lang`
58
+ // property if not (which would be set to the language’s directory name by default).
56
59
defaultLocale :
57
- config . defaultLocale . lang ?? config . defaultLocale . locale ?? BuiltInDefaultLocale . lang ,
60
+ config . defaultLocale . locale ?? config . defaultLocale . lang ?? BuiltInDefaultLocale . lang ,
58
61
locales : config . locales
59
62
? Object . entries ( config . locales ) . map ( ( [ locale , localeConfig ] ) => {
60
63
return {
You can’t perform that action at this time.
0 commit comments