Skip to content

Commit

Permalink
i18n(zh-cn): Update i18n.mdx (#2523)
Browse files Browse the repository at this point in the history
* i18n(zh-cn): Update `i18n.mdx`

* fix: missing translate and typo

---------

Co-authored-by: liruifengv <[email protected]>
  • Loading branch information
Nin3lee and liruifengv authored Oct 29, 2024
1 parent 1b46783 commit dd964f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/src/content/docs/zh-cn/guides/i18n.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ export const GET = (context) => {
}
```

The first UI string can be rendered by passing `'link.astro'` to the `t()` function:
第一个 UI 字符串可以通过将 `'link.astro'` 传递给 `t()` 函数来渲染:

```astro {3}
Expand All @@ -334,7 +333,7 @@ The first UI string can be rendered by passing `'link.astro'` to the `t()` funct

有关如何使用 `t()` 函数进行插值、格式化等更多信息,请参阅 [i18next 文档](https://www.i18next.com/overview/api#t)

### Advanced APIs
### 高级 API

#### `t.all()`

Expand Down Expand Up @@ -392,12 +391,13 @@ const arabicDirection = Astro.locals.t.dir('ar');

你可以使用 [`Astro.currentLocale`](https://docs.astro.build/zh-cn/reference/api-reference/#astrocurrentlocale)`.astro` 组件中读取当前的语言环境。

下面的示例读取当前语言环境,并使用它生成一个当前语言的关于页面的链接
下面的示例读取当前语言环境,并使用它和 [`getRelativeLocaleUrl()`](https://docs.astro.build/zh-cn/reference/modules/astro-i18n/#getrelativelocaleurl) 助手函数以生成一个当前语言的关于页面的链接

```astro
---
// src/components/AboutLink.astro
import { getRelativeLocaleUrl } from 'astro:i18n';
---
<a href={`/${Astro.currentLocale}/about`}>About</a>
<a href={getRelativeLocaleUrl(Astro.currentLocale ?? 'en', 'about')}>About</a>
```

0 comments on commit dd964f1

Please sign in to comment.