Skip to content

Commit

Permalink
i18n(zh-cn): Update some docs about #1620 & #1613 (#1835)
Browse files Browse the repository at this point in the history
Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Co-authored-by: huyikai <25839948+huyikai@users.noreply.github.com>
  • Loading branch information
3 people committed May 8, 2024
1 parent 9fe8475 commit 2bbed1b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 2 deletions.
28 changes: 28 additions & 0 deletions docs/src/content/docs/zh-cn/guides/i18n.mdx
Expand Up @@ -143,6 +143,34 @@ Starlight 期望你在所有语言中创建等效的页面。例如,如果你

如果某种语言尚未提供翻译,Starlight 将为读者显示该页面的默认语言(通过 `defaultLocale` 设置)的内容。例如,如果你尚未创建关于你的法语版本,并且你的默认语言是英语,那么访问 `/fr/about` 的访问者将看到来自 `/en/about` 的英语内容,并显示该页面尚未翻译的通知。这有助于你在默认语言中添加内容,然后在翻译人员有时间时逐步翻译它。

## 翻译网站标题

默认情况下,Starlight 会为所有语言使用相同的站点标题。
如果你需要为每种语言自定义标题,你可以在 Starlight 的选项中将一个对象传递给 [`title`](/zh-cn/reference/configuration/#title-必填)

```diff lang="js"
// astro.config.mjs
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

export default defineConfig({
integrations: [
starlight({
- title: 'My Docs',
+ title: {
+ en: 'My Docs',
+ 'zh-CN': '我的文档',
+ },
defaultLocale: 'en',
locales: {
en: { label: 'English' },
'zh-cn': { label: '简体中文', lang: 'zh-CN' },
},
}),
],
});
```

## 翻译 Starlight 的 UI

import LanguagesList from '~/components/languages-list.astro';
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/zh-cn/guides/pages.mdx
Expand Up @@ -107,6 +107,7 @@ import CustomComponent from './CustomComponent.astro';
- [`slug`](/zh-cn/reference/frontmatter/#slug) 属性不受支持,并且会根据自定义页面的 URL 自动设置。
- [`editUrl`](/zh-cn/reference/frontmatter/#editurl) 选项需要一个 URL 来显示编辑链接。
- 用于自定义页面如何在 [自动生成的链接组](/zh-cn/reference/configuration/#sidebar) 中显示的 [`sidebar`](/zh-cn/reference/frontmatter/#sidebar) frontmatter 属性不可用。使用 `<StarlightPage />` 组件的页面不是集合的一部分,不能添加到自动生成的侧边栏组中。
- [`draft`](/zh-cn/reference/frontmatter/#draft) 选项仅会显示页面为草稿的 [通知](/zh-cn/reference/overrides/#draftcontentnotice),但不会自动将其从生产版本中排除。

##### `sidebar`

Expand Down
14 changes: 13 additions & 1 deletion docs/src/content/docs/zh-cn/reference/configuration.mdx
Expand Up @@ -25,10 +25,22 @@ export default defineConfig({

### `title` (必填)

**类型:** `string`
**类型:** `string | Record<string, string>`

设置你的网站标题。将用于元数据和浏览器标签标题。

这个值可以是一个字符串,或者对于多语言网站,可以是一个包含每种不同语言值的对象。
当使用对象形式时,键必须是 BCP-47 标签(例如 `en``ar``zh-CN`):

```ts
starlight({
title: {
en: 'My delightful docs site',
de: 'Meine bezaubernde Dokumentationsseite',
},
});
```

### `description`

**类型:** `string`
Expand Down
15 changes: 15 additions & 0 deletions docs/src/content/docs/zh-cn/reference/frontmatter.md
Expand Up @@ -267,6 +267,21 @@ pagefind: false
---
```

### `draft`

**类型:** `boolean`
**默认值:** `false`

设置此页面是否应被视为草稿,并且不包含在 [生产版本](https://docs.astro.build/zh-cn/reference/cli-reference/#astro-build)[自动生成的链接组](/zh-cn/guides/sidebar/#自动生成的分组) 中。设置为 `true` 可将页面标记为草稿,并使其仅在开发过程中可见。

```md
---
# src/content/docs/example.md
# 从生产版本中排除此页面
draft: true
---
```

### `sidebar`

**类型:** [`SidebarConfig`](#sidebarconfig)
Expand Down
14 changes: 13 additions & 1 deletion docs/src/content/docs/zh-cn/reference/overrides.md
Expand Up @@ -50,6 +50,12 @@ Starlight 会将以下参数传递给你的自定义组件。

当前语言的根路径。对于默认语言来说是 `undefined`

#### `siteTitle`

**类型:** `string`

根据页面语言设置的网站标题。

#### `slug`

**类型:** `string`
Expand Down Expand Up @@ -218,7 +224,7 @@ entry: {
**默认组件:** [`Header.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/Header.astro)

在每个页面顶部显示的导航栏组件。
默认实现显示了 [`<SiteTitle />`](#sitetitle)[`<Search />`](#search)[`<SocialIcons />`](#socialicons)[`<ThemeSelect />`](#themeselect)[`<LanguageSelect />`](#languageselect)
默认实现显示了 [`<SiteTitle />`](#sitetitle-1)[`<Search />`](#search)[`<SocialIcons />`](#socialicons)[`<ThemeSelect />`](#themeselect)[`<LanguageSelect />`](#languageselect)

#### `SiteTitle`

Expand Down Expand Up @@ -332,6 +338,12 @@ Starlight 的页面侧边栏负责显示当前页面的子标题的目录。

自定义实现应确保在 `<h1>` 元素上设置 `id="_top"`,就像默认实现中一样。

#### `DraftContentNotice`

**默认组件:** [`DraftContentNotice.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/DraftContentNotice.astro)

在开发过程中,当当前页面被标记为草稿时,向用户显示的通知。

#### `FallbackContentNotice`

**默认组件:** [`FallbackContentNotice.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/FallbackContentNotice.astro)
Expand Down

0 comments on commit 2bbed1b

Please sign in to comment.