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

docs(cn): translate legacy/createElement into Chinese #1210

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

RexSkz
Copy link
Contributor

@RexSkz RexSkz commented Jun 23, 2023

翻译 legacy/createElement。

@github-actions
Copy link

github-actions bot commented Jun 23, 2023

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Three Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 76.72 KB (🟡 +53 B) 179.87 KB
/500 76.71 KB (🟡 +53 B) 179.87 KB
/[[...markdownPath]] 78.29 KB (🟡 +53 B) 181.44 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link
Collaborator

@Yucohny Yucohny left a comment

Choose a reason for hiding this comment

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

通篇都有一些表达值得再多考虑考虑。


### `createElement(type, props, ...children)` {/*createelement*/}

Call `createElement` to create a React element with the given `type`, `props`, and `children`.
调用 `createElement` 来创建一个 React 元素,它拥有给定的 `type``props` `children`
Copy link
Collaborator

Choose a reason for hiding this comment

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

表达有点拗口。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

确实,原文的意思应该是说“createElement 有这些参数”,而不是“元素有这些参数”。已修改。


* `type`: The `type` argument must be a valid React component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React component (a function, a class, or a special component like [`Fragment`](/reference/react/Fragment)).
* `type``type` 参数必须是一个有效的 React 组件类型。例如,它可以是一个标签名字符串(如 `'div'` `'span'`),或一个 React 组件(一个函数、一个类,或者是一个特殊的组件,比如 [`Fragment`](/reference/react/Fragment))。
Copy link
Collaborator

Choose a reason for hiding this comment

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

原文的意思应该是“函数式组件”、“类式组件”。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改。


* You must **treat React elements and their props as [immutable](https://en.wikipedia.org/wiki/Immutable_object)** and never change their contents after creation. In development, React will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) the returned element and its `props` property shallowly to enforce this.
* 你必须 **把 React 元素和它们的 props 视为[不可变的](https://en.wikipedia.org/wiki/Immutable_object)**,并且在创建后永远不要改变它们的内容。在开发环境中,React 会浅层 [冻结](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) 返回的元素及其 `props` 属性,以强制执行此操作。
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* 你必须 **把 React 元素和它们的 props 视为[不可变的](https://en.wikipedia.org/wiki/Immutable_object)**,并且在创建后永远不要改变它们的内容。在开发环境中,React 会浅层 [冻结](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) 返回的元素及其 `props` 属性,以强制执行此操作。
* 你必须 **把 React 元素和它们的 props 视为 [不可变的](https://en.wikipedia.org/wiki/Immutable_object)**,并且在创建后永远不要改变它们的内容。在开发环境中,React 会浅层 [冻结](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) 返回的元素及其 `props` 属性,以强制执行此操作。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改。

},
key: null,
ref: null,
}
```

**Note that creating this object does not render the `Greeting` component or create any DOM elements.**
**注意,创建这个对象并不会渲染 `Greeting` 组件或者创建任何 DOM 元素。**
Copy link
Collaborator

Choose a reason for hiding this comment

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

句末标点移至加粗外。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改。

P.S. 这个规则是无条件的吗?如果加粗是句内的一部分还可以理解,但整段加粗的情况下句末标点也需要放在外面,感觉就有点怪了。

Copy link
Collaborator

Choose a reason for hiding this comment

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

是的,参考翻译规范。

@RexSkz
Copy link
Contributor Author

RexSkz commented Jun 25, 2023

对于翻译时要求直译或意译,有什么可以参考的指南吗?有些表达直译过来确实有些绕,我有改动过一些表述(如 it will be treated the same as an empty object 直译是 它将被视为与空对象相同,我改成了 它将被当作一个空对象),但大部分尽量忠于原文。

如果依旧有很多地方拗口,我可以再多做一些这样的改动,例如 it's best to treat every element as opaque after it's created, and only render it 目前的翻译是 最好在创建后将每个元素都视为不透明的,并且只渲染它,不过翻译为 最好将创建的每个元素都视为黑盒,只做渲染 会更符合中文的习惯。如果这种修改没有问题,我就也改一下~

@Yucohny
Copy link
Collaborator

Yucohny commented Jun 25, 2023

对于翻译时要求直译或意译,有什么可以参考的指南吗?有些表达直译过来确实有些绕,我有改动过一些表述(如 it will be treated the same as an empty object 直译是 它将被视为与空对象相同,我改成了 它将被当作一个空对象),但大部分尽量忠于原文。

如果依旧有很多地方拗口,我可以再多做一些这样的改动,例如 it's best to treat every element as opaque after it's created, and only render it 目前的翻译是 最好在创建后将每个元素都视为不透明的,并且只渲染它,不过翻译为 最好将创建的每个元素都视为黑盒,只做渲染 会更符合中文的习惯。如果这种修改没有问题,我就也改一下~

我的个人观点是,在保证原文意思不变的情况下,可以大胆“意译”。

@RexSkz
Copy link
Contributor Author

RexSkz commented Jun 25, 2023

@RexSkz RexSkz force-pushed the rex/legacy-create-element branch from 157cc79 to 80e282d Compare June 28, 2023 07:49
@RexSkz
Copy link
Contributor Author

RexSkz commented Jun 28, 2023

rebase 了一下 main 分支,还有其它问题需要解决吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Modify 已校对,待修改阶段
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants