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

New Crowdin updates #8

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
8 changes: 3 additions & 5 deletions docs/zh/guide/apis/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ $app([], _ => {

```ts
$app([], _ => {
_.$ev; // ERROR: Property '$ev' does not exist on type 'Context'.
_.$ev; // 错误: 'Context' 上不存在 '$ev'。

if (_.button("Click me")) {
_.$ev; // of type MouseEvent
_.$ev; // 类型为 MouseEvent
}
});
```
Expand Down Expand Up @@ -102,8 +102,6 @@ $app([], _ => {

:::info

It is usually a bad idea to write to `_.$runtimeData` directly,
which is not scoped to children,
use `_.provide` to provide values to `_.$runtimeData` instead.
通常你不需要直接读写 `_.$runtimeData`,因为它可能会从可控的作用域泄露。请使用 `_.provide` 方法向一定范围内提供值。

:::
2 changes: 1 addition & 1 deletion docs/zh/guide/apis/util-funcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ _.asyncEmbed(() => import("./someContent.ts"));

## `_.provide`

Provide a value or an object of values to [`_.$runtimeData`](./directives.md#runtime-data) for the duration of children.
提供一组键值或一个对象到 [`_.$runtimeData`](./directives.md#runtime-data),并且这些值与对象仅在内部有效。

**例子**

Expand Down
8 changes: 4 additions & 4 deletions docs/zh/guide/essentials/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $app([Basics], _ => {
type D<T> = T | PD<T>;
```

### The `unwrap` Function
### `unwrap` 函数

该函数可以从类型为 `Model` 的值中取出原始值。

Expand All @@ -71,13 +71,13 @@ assert(unwrap(wrappedValue) === 1);

:::info

If the wrapped value is defined via `model` function, it is of type `JustModel<T>`, so you don't need to use `unwrap` function to extract the value. 你可以直接访问 `yourModel.value`.
`model` 函数创建值的类型是 `JustModel<T>`, 因此你不需要使用 `unwrap` 函数。 你可以直接访问 `wrappedValue.value`. 你可以直接访问 `yourModel.value`.

:::

### `_.$setD` 函数
### `_.$updateModel` 函数

Corresponding to `unwrap` function, this function can update the value of a model.
`unwrap` 函数相对应,这个函数可以设置类型为 `Model` 中的数据的值,并触发应用的更新。

## 另一种获取用户输入的方式。

Expand Down
6 changes: 3 additions & 3 deletions docs/zh/guide/essentials/lowlevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const app = $app([], _ => {

- 参数:(均为可选参数)
- `data`: 将被合并到元素实例的对象。
- `children`: the children of the element.
- `children`: 子元素。
- `eventListeners`: 元素的事件侦听器。
- 返回值: `void`

Expand Down Expand Up @@ -122,14 +122,14 @@ for (const key in data) {
}
```

## The `children` Parameter
## `children` 参数

**类型**: `D<Content>`

元素的内容(即打开、闭合标签之间的东西)。 它可以是:

- 一个字符串或数字,将被以字符串节点的形式渲染。
- A view function, which will be rendered as the content of the element.
- 一个视图函数,将调用它以渲染内部的元素。
- 一个包裹了上述2种之一的 `PD` 对象。

## `eventListeners` 参数
Expand Down
8 changes: 4 additions & 4 deletions docs/zh/guide/essentials/rendering-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ $app([Basics], _ => {

许多组件都有一个或多个内容。它们对应渲染的 HTML 的一部分。

You can not only pass a string or a number as the content but also pass a view function.
你不但可以将字符串或数字作为内容传入,也可以使用视图函数。

:::tip

When using view functions as the content of a component, it is recommended to use the arrow function syntax.
当使用视图函数作为组件的内容时,推荐使用箭头函数。

为了获取最佳的开发体验,你可以使用 [Prettier](https://prettier.io/) 来格式化代码,并将 `arrowParens` 设置为 `"avoid"`。

Expand All @@ -49,9 +49,9 @@ When using view functions as the content of a component, it is recommended to us

:::tip

The curly braces around the view function can be omitted if the view function has only one statement.
如果视图函数只有一个语句,那么箭头函数的花括号可以省略。

This is because the return value of the view function will always be ignored.
这是因为视图函数的返回值总是会被忽略。

你也可以使用 `&&` 来将数个一定返回真值的语句和最后一个语句连接,将多个语句转换为表达式,并省去花括号。

Expand Down
6 changes: 3 additions & 3 deletions docs/zh/guide/essentials/view.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $app([], _ => {

## 传入视图参数 {#passing-parameters}

A view can have parameters:
一个视图可以有参数:

```ts
import { $view, _ } from "refina";
Expand All @@ -57,7 +57,7 @@ export default $view((name: string, id?: number) => {
});
```

Then, you can pass the parameters to the view:
然后可以这样向视图传递参数:

```ts
_(MyView)("John", 123);
Expand Down Expand Up @@ -97,7 +97,7 @@ export default $view(_ => {

### 如何选择

If you want to reuse a **view function of the page**, you should use a _view_.
如果你想复用**页面的片段**,可以使用 _视图_。

如果你想复用**有状态的代码**,你需要使用_组件_。

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/tutorial/src/step-2/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare module "refina" {
}
```

组件的一些参数代表“内容”(子元素)。 You can pass a string, a number or a function (we call it "view function") to it:
组件的一些参数代表“内容”(子元素)。 你可以向它们传入字符串、数字或者是视图函数。

```ts
$app([Basics], _ => {
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/tutorial/src/step-4/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ $app([Basics], _ => {
});
```

:::warning States should be declared outside the main function.
:::warning 状态应当定义在主函数的外部

Variables declared inside the main function are not states. They are just local temporary variables, which are re-created every time the main function is called.
在主函数内部定义的函数不是状态。 它们只是局部的临时变量,每当主函数被调用时都会重新创建。

:::

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/tutorial/src/step-8/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default $view((id: number) => {
});
```

To use a view, just call the context object:
调用上下文对象以使用视图:

```ts
import { $app } from "refina";
Expand Down