From b790c92a51717980a10f1210efa745cdcbbe0872 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:39 +0800 Subject: [PATCH 1/9] New translations input.md (Chinese Simplified) --- docs/zh/guide/essentials/input.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/zh/guide/essentials/input.md b/docs/zh/guide/essentials/input.md index ba138225..2c1db5aa 100644 --- a/docs/zh/guide/essentials/input.md +++ b/docs/zh/guide/essentials/input.md @@ -57,7 +57,7 @@ $app([Basics], _ => { type D = T | PD; ``` -### The `unwrap` Function +### `unwrap` 函数 该函数可以从类型为 `Model` 的值中取出原始值。 @@ -71,13 +71,13 @@ assert(unwrap(wrappedValue) === 1); :::info -If the wrapped value is defined via `model` function, it is of type `JustModel`, so you don't need to use `unwrap` function to extract the value. 你可以直接访问 `yourModel.value`. +由 `model` 函数创建值的类型是 `JustModel`, 因此你不需要使用 `unwrap` 函数。 你可以直接访问 `wrappedValue.value`. 你可以直接访问 `yourModel.value`. ::: -### `_.$setD` 函数 +### `_.$updateModel` 函数 -Corresponding to `unwrap` function, this function can update the value of a model. +与 `unwrap` 函数相对应,这个函数可以设置类型为 `Model` 中的数据的值,并触发应用的更新。 ## 另一种获取用户输入的方式。 From 76eed5a3dff500481695c0fd8c9cbcc795ffd42c Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:41 +0800 Subject: [PATCH 2/9] New translations lowlevel.md (Chinese Simplified) --- docs/zh/guide/essentials/lowlevel.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/zh/guide/essentials/lowlevel.md b/docs/zh/guide/essentials/lowlevel.md index 0214684e..8c6f9c50 100644 --- a/docs/zh/guide/essentials/lowlevel.md +++ b/docs/zh/guide/essentials/lowlevel.md @@ -76,7 +76,7 @@ const app = $app([], _ => { - 参数:(均为可选参数) - `data`: 将被合并到元素实例的对象。 - - `children`: the children of the element. + - `children`: 子元素。 - `eventListeners`: 元素的事件侦听器。 - 返回值: `void` @@ -122,14 +122,14 @@ for (const key in data) { } ``` -## The `children` Parameter +## `children` 参数 **类型**: `D` 元素的内容(即打开、闭合标签之间的东西)。 它可以是: - 一个字符串或数字,将被以字符串节点的形式渲染。 -- A view function, which will be rendered as the content of the element. +- 一个视图函数,将调用它以渲染内部的元素。 - 一个包裹了上述2种之一的 `PD` 对象。 ## `eventListeners` 参数 From 1e4fbcd75ac0b131bca58444e5b5e2a12c4bebac Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:42 +0800 Subject: [PATCH 3/9] New translations rendering-basics.md (Chinese Simplified) --- docs/zh/guide/essentials/rendering-basics.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/zh/guide/essentials/rendering-basics.md b/docs/zh/guide/essentials/rendering-basics.md index 57cad685..1322a718 100644 --- a/docs/zh/guide/essentials/rendering-basics.md +++ b/docs/zh/guide/essentials/rendering-basics.md @@ -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"`。 @@ -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. +这是因为视图函数的返回值总是会被忽略。 你也可以使用 `&&` 来将数个一定返回真值的语句和最后一个语句连接,将多个语句转换为表达式,并省去花括号。 From 298337a7c7dce545ce39af21e7471862f6baa9a5 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:43 +0800 Subject: [PATCH 4/9] New translations view.md (Chinese Simplified) --- docs/zh/guide/essentials/view.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/zh/guide/essentials/view.md b/docs/zh/guide/essentials/view.md index b485a5a4..dcde259a 100644 --- a/docs/zh/guide/essentials/view.md +++ b/docs/zh/guide/essentials/view.md @@ -44,7 +44,7 @@ $app([], _ => { ## 传入视图参数 {#passing-parameters} -A view can have parameters: +一个视图可以有参数: ```ts import { $view, _ } from "refina"; @@ -57,7 +57,7 @@ export default $view((name: string, id?: number) => { }); ``` -Then, you can pass the parameters to the view: +然后可以这样向视图传递参数: ```ts _(MyView)("John", 123); @@ -97,7 +97,7 @@ export default $view(_ => { ### 如何选择 -If you want to reuse a **view function of the page**, you should use a _view_. +如果你想复用**页面的片段**,可以使用 _视图_。 如果你想复用**有状态的代码**,你需要使用_组件_。 From 04f6cc806c71ea4a2fc2901cc4c0821629477ef8 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:44 +0800 Subject: [PATCH 5/9] New translations directives.md (Chinese Simplified) --- docs/zh/guide/apis/directives.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/zh/guide/apis/directives.md b/docs/zh/guide/apis/directives.md index f85649c6..486e488d 100644 --- a/docs/zh/guide/apis/directives.md +++ b/docs/zh/guide/apis/directives.md @@ -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 } }); ``` @@ -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` 方法向一定范围内提供值。 ::: From deda00346bb9305ef78083467c1973c6556f1298 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:45 +0800 Subject: [PATCH 6/9] New translations util-funcs.md (Chinese Simplified) --- docs/zh/guide/apis/util-funcs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/guide/apis/util-funcs.md b/docs/zh/guide/apis/util-funcs.md index b17e39f6..ae0fff6c 100644 --- a/docs/zh/guide/apis/util-funcs.md +++ b/docs/zh/guide/apis/util-funcs.md @@ -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),并且这些值与对象仅在内部有效。 **例子** From 756a0430e03c15fc240584f143012ad9112e2c66 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:46 +0800 Subject: [PATCH 7/9] New translations description.md (Chinese Simplified) --- docs/zh/tutorial/src/step-2/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/tutorial/src/step-2/description.md b/docs/zh/tutorial/src/step-2/description.md index 134c34e6..02a750f6 100644 --- a/docs/zh/tutorial/src/step-2/description.md +++ b/docs/zh/tutorial/src/step-2/description.md @@ -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], _ => { From 81a5145731a149d1aeff9af9393d40af59013bf2 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:47 +0800 Subject: [PATCH 8/9] New translations description.md (Chinese Simplified) --- docs/zh/tutorial/src/step-4/description.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh/tutorial/src/step-4/description.md b/docs/zh/tutorial/src/step-4/description.md index 8b5b4f8e..483a876c 100644 --- a/docs/zh/tutorial/src/step-4/description.md +++ b/docs/zh/tutorial/src/step-4/description.md @@ -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. +在主函数内部定义的函数不是状态。 它们只是局部的临时变量,每当主函数被调用时都会重新创建。 ::: From 6c08577a630a9d9ac99aed9ef22096257a238882 Mon Sep 17 00:00:00 2001 From: _Kerman Date: Mon, 29 Jan 2024 22:29:48 +0800 Subject: [PATCH 9/9] New translations description.md (Chinese Simplified) --- docs/zh/tutorial/src/step-8/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/tutorial/src/step-8/description.md b/docs/zh/tutorial/src/step-8/description.md index b8816bc0..a6df545b 100644 --- a/docs/zh/tutorial/src/step-8/description.md +++ b/docs/zh/tutorial/src/step-8/description.md @@ -14,7 +14,7 @@ export default $view((id: number) => { }); ``` -To use a view, just call the context object: +调用上下文对象以使用视图: ```ts import { $app } from "refina";