Skip to content

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

Open
@Yuelioi

Description

@Yuelioi

What version of starlight are you using?

0.33.1

What version of astro are you using?

5.6.1

What package manager are you using?

pnpm

What operating system are you using?

window

What browser are you using?

chrome

Describe the Bug

I want to set the defaultLocale to zh-cn, but all config is error,

docs: starlight i18n

1.The default locale zh-CN is not present in the i18n.locales array.

  defaultLocale: "zh-cn",  
      locales: {
        en: {
          label: "English",
        },
        "zh-cn": {
          label: "简体中文",
          lang: "zh-cn",
        },
      },

2.Could not determine the default locale. Please make sure defaultLocale in your Starlight config is one of "en", "zh-cn"

  defaultLocale: "zh-CN", 
      locales: {
        en: {
          label: "English",
        },
        "zh-cn": {
          label: "简体中文",
          lang: "zh-cn",
        },
      },
  1. this config can work, but when i chage to zh-CN, like http://localhost:4322/zh-CN/guides/example/ andhttp://localhost:4322/zh-CN/guides/example/

The slug "guides/example" specified in the Starlight sidebar config does not exist.

 defaultLocale: "zh-CN", 
      locales: {
        en: {
          label: "English",
        },
        "zh-CN": {  <=
          label: "简体中文",
          lang: "zh-cn",
        },
      },

full config

export default defineConfig({
  integrations: [
    starlight({
      title: "My Docs",
      social: [{ icon: "github", label: "GitHub", href: "https://github.com/withastro/starlight" }],
      defaultLocale: "zh-CN",
      locales: {
        en: {
          label: "English",
        },
        "zh-CN": {
          label: "简体中文",
          lang: "zh-cn",
        },
      },
      sidebar: [
        {
          label: "Guides",
          items: [{ label: "Example Guide", slug: "guides/example" }],
        },
        {
          label: "Reference",
          autogenerate: { directory: "reference" },
        },
      ],
    }),
  ],
});

My file tree

content/docs/en/guide..
content/docs/zh-cn/guide..

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-4evqycls?file=README.md

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions