Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n(zh-cn): translate guides/actions.mdx into Chinese(Simplified) #9439

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CaptainOfPhB
Copy link
Contributor

Description (required)

Translate the /en/guides/actions into Chinese(Simplified).

@github-actions github-actions bot added the i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help! label Sep 18, 2024
Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9dedbd4
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/66eaa18e74ab4d0008eaf18f
😎 Deploy Preview https://deploy-preview-9439--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Sep 18, 2024

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
zh-cn guides/actions.mdx Localization added, will be marked as complete.
zh-cn reference/api-reference.mdx Localization changed, will be marked as complete.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.


使用 actions 而不是 API 端点,以实现客户端和服务器代码之间的无缝通信,并且可以:

- 使用 [Zod 校验](https://zod.dev/?id=primitives)自动校验 JSON 和表单数据输入。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- 使用 [Zod 校验](https://zod.dev/?id=primitives)自动校验 JSON 和表单数据输入。
- 使用 [Zod 校验](https://zod.dev/README_ZH?id=原始类型)自动校验 JSON 和表单数据输入。

我把它更新成了官方的中文文档链接~

}
```

3. 使用 `defineAction()` 工具定义一个 `getGreeting` action。`input` 属性将使用 [Zod](https://zod.dev) 模式验证输入参数,`handler()` 函数包含要在服务器上运行的后端逻辑。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
3. 使用 `defineAction()` 工具定义一个 `getGreeting` action。`input` 属性将使用 [Zod](https://zod.dev) 模式验证输入参数`handler()` 函数包含要在服务器上运行的后端逻辑。
3. 使用 `defineAction()` 工具定义一个 `getGreeting` action。`input` 属性将使用 [Zod](https://zod.dev/README_ZH) scheme 验证输入参数`handler()` 函数包含要在服务器上运行的后端逻辑。

}
```

然后,你可以将此 `user` 对象导入到你的 `src/actions/index.ts` 文件中,并将其添加为 `server` 对象中的顶级键,以及任何其他 actions:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
然后,你可以将此 `user` 对象导入到你的 `src/actions/index.ts` 文件中,并将其添加为 `server` 对象中的顶级键,以及任何其他 actions
然后,你可以将此 `user` 对象导入到你的 `src/actions/index.ts` 文件中,并将其作为顶层键与任何其他 actions 一起添加到 `server` 对象中


## 处理返回的数据

Actions 返回一个对象,其中包含 `data`,它是 `handler()` 的具备类型安全的返回值,或者是一个 `error`,其中包含任何后端错误。错误可能来自 `input` 属性上的验证错误,或者来自 `handler()` 中抛出的错误。
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Actions 返回一个对象,其中包含 `data`,它是 `handler()` 的具备类型安全的返回值,或者是一个 `error`,其中包含任何后端错误。错误可能来自 `input` 属性上的验证错误,或者来自 `handler()` 中抛出的错误。
Actions 会返回一个对象,这个对象要么是具备 `handler()` 类型安全性的返回值 `data`,要么是包含着任何后端错误的 `error`。错误可能来自 `input` 属性上的验证错误,或者来自 `handler()` 中抛出的错误。

我把句中的 either...or... 语义加入并润色了一下。


```ts ins="orThrow"
const updatedLikes = await actions.likePost.orThrow({ postId: 'example' });
// ^ type: number
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ^ type: number
// ^ 类型:number

---

<form method="POST" action={actions.logout}>
<button>Log out</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<button>Log out</button>
<button>退出登录</button>


<form method="POST" action={'/confirmation' + actions.newsletter}>
<label>E-mail <input required type="email" name="email" /></label>
<button>Sign up</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<button>Sign up</button>
<button>注册</button>

Comment on lines +493 to +500
<p class="error">Unable to sign up. Please try again later.</p>
)}
<form method="POST" action={'/confirmation' + actions.newsletter}>
<label>
E-mail
<input required type="email" name="email" />
</label>
<button>Sign up</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<p class="error">Unable to sign up. Please try again later.</p>
)}
<form method="POST" action={'/confirmation' + actions.newsletter}>
<label>
E-mail
<input required type="email" name="email" />
</label>
<button>Sign up</button>
<p class="error">无法注册。请稍后再试。</p>
)}
<form method="POST" action={'/confirmation' + actions.newsletter}>
<label>
E-mail
<input required type="email" name="email" />
</label>
<button>注册</button>

<input required type="email" name="email" aria-describedby="error" />
</label>
{inputErrors.email && <p id="error">{inputErrors.email.join(',')}</p>}
<button>Sign up</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<button>Sign up</button>
<button>注册</button>

---

{result && !result.error && (
<p class="success">Added {result.data.productName} to cart</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<p class="success">Added {result.data.productName} to cart</p>
<p class="success">添加 {result.data.productName} 到购物车</p>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n Anything to do with internationalization & translation efforts - ask @YanThomas for help!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants