docs: add chinese translation for conditionals-and-interactivity#1192
docs: add chinese translation for conditionals-and-interactivity#1192SihongShen wants to merge 4 commits intoprocessing:mainfrom
Conversation
|
Hi @lirenjie95! I've completed the translation for conditionals-and-interactivity.mdx, please review it. I failed to check the result because of the issue mentioned in #1187, please tell me if further changes are needed. Thank you! |
lirenjie95
left a comment
There was a problem hiding this comment.
Hi @SihongShen Thank you for your contribution! I've left some suggestions in the code review section—please feel free to take a look when you have a moment. Also, I noticed that this PR addresses but doesn't fully resolve the related issue, as there are still other language translations missing. Would you mind updating the PR description to use "addresses #1150" instead? This helps keep our issue tracking accurate. Thanks again for your work on this!
| <table> | ||
|
|
||
| <tr> | ||
|
|
||
| <th> | ||
|
|
||
| 符号 | ||
|
|
||
| </th> | ||
|
|
||
| <th> | ||
|
|
||
| 含义(p5.js参考链接) | ||
|
|
||
| </th> | ||
|
|
||
| <th> | ||
|
|
||
| 示例 | ||
|
|
||
| </th> | ||
|
|
||
| </tr> | ||
|
|
||
| <tr> | ||
|
|
||
| <td> | ||
|
|
||
| `<` | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| [小于](/reference/p5/lt) | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| `x < 5` | ||
|
|
||
| </td> | ||
|
|
||
| </tr> | ||
|
|
||
| <tr> | ||
|
|
||
| <td> | ||
|
|
||
| `<=` | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| [小于或等于](/reference/p5/lte) | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| `x <= 5` | ||
|
|
||
| </td> | ||
|
|
||
| </tr> | ||
|
|
||
| <tr> | ||
|
|
||
| <td> | ||
|
|
||
| `>` | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| [大于](/reference/p5/gt) | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| `x > 5` | ||
|
|
||
| </td> | ||
|
|
||
| </tr> | ||
|
|
||
| <tr> | ||
|
|
||
| <td> | ||
|
|
||
| `>=` | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| [大于或等于](/reference/p5/gte) | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| `x >= 5` | ||
|
|
||
| </td> | ||
|
|
||
| </tr> | ||
|
|
||
| <tr> | ||
|
|
||
| <td> | ||
|
|
||
| `===` | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| 严格相等 (意味着不同类型的值会被视为不相等) | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| `x === 5` | ||
|
|
||
| </td> | ||
|
|
||
| </tr> | ||
|
|
||
| <tr> | ||
|
|
||
| <td> | ||
|
|
||
| `!==` | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| 不等于 | ||
|
|
||
| </td> | ||
|
|
||
| <td> | ||
|
|
||
| `x !== 5` | ||
|
|
||
| </td> | ||
|
|
||
| </tr> | ||
|
|
||
| </table> |
There was a problem hiding this comment.
This table appears to be malformed. Would you mind adjusting it to a properly indented structure?
There was a problem hiding this comment.
Looks like the original table is also in this kind format...
I'll leave it as an enhancement. Not strictly required.
| category: introduction | ||
| categoryIndex: 3 | ||
| featuredImage: ../images/featured/ConditionalsA.png | ||
| featuredImageAlt: 条件语句与交互性教程作品的预览,是一个日出动画。 |
There was a problem hiding this comment.
这里有点拗口,改成“用条件语句与交互创建的日出动画的预览”会不会更好?或者你有其他好的表达也可以替换上。
| - [`circle()`](/reference/p5/circle) | [`rect()`](/reference/p5/rect) | [`ellipse()`](/reference/p5/ellipse) | [`triangle()`](/reference/p5/triangle) | [`line()`](/reference/p5/line) | ||
| - [`fill()`](/reference/p5/fill), [`stroke()`](/reference/p5/stroke), [`text()`](/reference/p5/text), [`textSize()`](/reference/p5/textSize) | ||
| - 使用包括 [`mouseX`](/reference/p5/mouseX) 和 [`mouseY`](/reference/p5/mouseY) 等在内的内置变量 | ||
| - 使用 `let` 和 [赋值运算符](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment) 来声明,初始化,使用和更新自定义变量 |
|
|
||
| - 打开一个新的p5.js项目,命名为 “Interactive Sun”,并保存该草图(sketch)。 | ||
|
|
||
| - 声明一个名为 `sunHeight` 的自定义变量,用于表示太阳的 y 坐标 和一个声明一个名为 `horizon` 的自定义变量,用于表示地平线的 y 坐标。将 horizon 变量初始化为 200。 |
| } | ||
| ``` | ||
|
|
||
| 由于太阳的高度是变化的,我们将鼠标的 y 坐标 (`mouseY`)在变量 `sunHeight` 中。在函数 `draw()` 中执行此操作可以保证每次 `draw()` 运行时,`sunHeight` 都会持续更新。虽然地平线的位置保持不变,但为它设置一个自定义变量可以作为参考点,并提高代码的可读性。 |
There was a problem hiding this comment.
“在变量sunHeight中”成分残缺,应改为“存储在变量 sunHeight中”或“赋值给变量sunHeight”
|
|
||
| 这样当草图运行时,太阳就会自动移动了!这是因为每次 [`draw()`](/reference/p5/draw) 运行时,变量 `sunHeight` 的值都会减少2。一旦if 语句中的布尔表达式 `sunHeight > 130` 变为 `false`,变量 `sunHeight` 就不再减少了。 | ||
|
|
||
| 当一个变量的值减少时,这被称为*递减*,并使用*减法赋值*符号 `-= ` 。当变量的值增加时,这被称为*递增*,并使用*加法赋值*符号 `+=` 。每当一个变量递增或递减时,存储在该变量中的值都会发生改变,并且存入新值。 |
There was a problem hiding this comment.
原文是"When the value in a variable decreases by a value, it is called decrementing, and the subtract assign -= symbol is used." 后半句用的and这种情况下表示时间先后关系,并不是并列关系。建议改为"这称为递减,使用减法赋值运算符 -= 表示"。
There was a problem hiding this comment.
本行最后面的“并且存入新值”也有一样的问题。可以去掉“并且”。
| [示例](https://editor.p5js.org/gbenedis@gmail.com/sketches/IHAcGOxNz) | ||
| </Callout> | ||
|
|
||
| 天空颜色的改变是因为 `redVal` 和 `greenVal` 的值在逐渐改变。根据第二个条件语句中的布尔表达式,当 `sunHeight` 小于 480 时,颜色变量开始改变:`redVal` 每次增加4,`greenVal` 每次增加1。 每次 [`draw()`](/reference/p5/draw) 运行时,`redVal` 和 `greenVal` 的值都会增加,并且在下一次运行时被用来改变背景颜色。这就创造了一个动画的日出效果。 |
There was a problem hiding this comment.
最后一句“这就创造了一个动画的日出效果”
这是笔误吧😂
|
|
||
| 天空颜色的改变是因为 `redVal` 和 `greenVal` 的值在逐渐改变。根据第二个条件语句中的布尔表达式,当 `sunHeight` 小于 480 时,颜色变量开始改变:`redVal` 每次增加4,`greenVal` 每次增加1。 每次 [`draw()`](/reference/p5/draw) 运行时,`redVal` 和 `greenVal` 的值都会增加,并且在下一次运行时被用来改变背景颜色。这就创造了一个动画的日出效果。 | ||
|
|
||
| 语句 `redVal += 4` 也可以写成 `greenVal++`。`++` 被称为**递增运算符**,而 `--` 被称为**递减运算符**。 |
There was a problem hiding this comment.
原文为The statement greenVal +=1 can also be written as greenVal++
变量名字写错了
|
|
||
| 查看[这个示例](https://editor.p5js.org/Msqcoding/sketches/CnKfDeaBG)观察当鼠标按键按下时,`mouseIsPressed` 的值在控制台中是如何变化的。 | ||
|
|
||
| 在“试试这个!”挑战中,当 `sunHeight` 等于 130 *且* 鼠标按键被按下时,天空变暗了。也许它展示了一个日食! |
There was a problem hiding this comment.
“也许它展示了一个日食!”翻译略显生硬。这种中文不存在的表达Perhaps it shows a solar eclipse! 可以把主语进行省略。
| } | ||
| ``` | ||
|
|
||
| 由于 `mouseIsPressed` 已经存储了 `true` 或 `false` 的值,我们就不需要使用比较运算符来创建一个布尔表达式。布尔表达式的结果是布尔值,而布尔变量储存布尔值。条件语句只需要布尔值。条件语句只需要布尔值为 `true` 时才会运行代码。如果 `mouseIsPressed` 是 `true`,条件语句的代码块就会运行。 |
There was a problem hiding this comment.
“条件语句只需要布尔值。条件语句只需要布尔值为 true 时才会运行代码。”这里有笔误,前半句多写了一遍。
|
@lirenjie95 Thank you so much for your detailed suggestions! I've completed the revising the translations as well we trying to modify the table. Thank you again for your review! |
Update the translation needed in #1150
Adds the Chinese translation for the Conditionals and Interactivity tutorial.