Skip to content

doc: translate hooks-overview #35

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

Merged
merged 2 commits into from
Mar 23, 2019
Merged

Conversation

BruceWeng
Copy link
Contributor

@BruceWeng BruceWeng commented Mar 9, 2019

Ready to review!
I made an independent PR for each article for easier merging.

I will keep doc: Translate Hooks #32 open until all the Hooks topics are done.
I will track the Hooks translation progress there, which will be friendly for newcomers following current progress.

Also, I find it hard to avoid my hooks-intro.md work. Please cherry-pick hooks-overview.md commits in this PR and I will pull the result on master and start from there on my next translation.

Let me know if you have any thought!

Update: I have resolved conflict on hooks-intro.md by deleting my part. This PR should have no collision with the master branch now.

@netlify
Copy link

netlify bot commented Mar 9, 2019

Deploy preview for zh-hant-reactjs-org ready!

Built with commit c43ad02

https://deploy-preview-35--zh-hant-reactjs-org.netlify.com

Copy link
Member

@chloewlin chloewlin left a comment

Choose a reason for hiding this comment

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

Hi @BruceWeng! In another PR, you used "Hook" (singular) consistently over the entire translation. But here you alternate between "Hooks" and "Hook". Can you fix them?

Also, please take a look at the glossary: https://github.com/reactjs/zh-hant.reactjs.org/wiki/Glossary
These are the words the community agrees to keep in English.

I didn't fix everything in this PR. Can you fix the rest? Thanks!

@@ -1,30 +1,30 @@
---
id: hooks-overview
title: Hooks at a Glance
title: 第一眼 Hooks
Copy link
Member

Choose a reason for hiding this comment

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

At a glance does not mean 第一眼. It means a brief summary.

Suggested change
title: 第一眼 Hooks
title: Hook 概論

permalink: docs/hooks-overview.html
next: hooks-state.html
prev: hooks-intro.html
---

*Hooks* are a new addition in React 16.8. They let you use state and other React features without writing a class.
*Hooks* React 16.8 新加的功能,他們讓你可以不用寫 class 就能使用 state 與其他 React 的功能。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*Hooks* 是 React 16.8 新加的功能,他們讓你可以不用寫 class 就能使用 state 與其他 React 的功能。
*Hook* 是 React 16.8 新加的功能,他們讓你可以不用寫 class 就能使用 state 與其他 React 的功能。

Singular.


Hooks are [backwards-compatible](/docs/hooks-intro.html#no-breaking-changes). This page provides an overview of Hooks for experienced React users. This is a fast-paced overview. If you get confused, look for a yellow box like this:
Hooks [向後兼容](/docs/hooks-intro.html#no-breaking-changes)。這一頁提供 Hooks 的簡介給有經驗的 React 使用者們。這是一個快節奏的簡介,如果你有疑惑,看一下黃色框框如下:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Hooks [向後兼容](/docs/hooks-intro.html#no-breaking-changes)。這一頁提供 Hooks 的簡介給有經驗的 React 使用者們。這是一個快節奏的簡介,如果你有疑惑,看一下黃色框框如下:
Hook [向後兼容](/docs/hooks-intro.html#no-breaking-changes)。這一頁提供 Hook 的簡介給有經驗的 React 使用者們。這是一個快節奏的簡介,如果你有疑惑,看一下黃色框框如下:

Singular

>
>Read the [Motivation](/docs/hooks-intro.html#motivation) to learn why we're introducing Hooks to React.
>讀[動機](/docs/hooks-intro.html#motivation)來了解為什麼我們將 Hooks 加入 React
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>[動機](/docs/hooks-intro.html#motivation)來了解為什麼我們將 Hooks 加入 React。
>[動機](/docs/hooks-intro.html#motivation)來了解為什麼我們將 Hook 加入 React。


**↑↑↑ Each section ends with a yellow box like this.** They link to detailed explanations.
**↑↑↑ 每一個章節結束都有一個黃色框框像這樣。**他們連到詳細解釋。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
**↑↑↑ 每一個章節結束都有一個黃色框框像這樣。**他們連到詳細解釋。
**↑↑↑ 每一個章節結束都有一個黃色框框像這樣。** 他們連到詳細解釋。

Not properly bolded.
Screen Shot 2019-03-13 at 1 37 08 AM


## 🔌 Other Hooks {#other-hooks}
## 🔌 其他 Hooks {#other-hooks}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## 🔌 其他 Hooks {#other-hooks}
## 🔌 其他 Hook {#other-hooks}

>
>You can learn more about all the built-in Hooks on a dedicated page: [Hooks API Reference](/docs/hooks-reference.html).
>你可以在 [Hooks API Reference](/docs/hooks-reference.html) 了解更多所有的內建 Hooks。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>你可以在 [Hooks API Reference](/docs/hooks-reference.html) 了解更多所有的內建 Hooks
>你可以在 [Hooks API Reference](/docs/hooks-reference.html) 了解更多所有的內建 Hook

- id: hooks-overview
title: Hooks at a Glance
title: 第一眼 Hooks
Copy link
Member

Choose a reason for hiding this comment

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

Again, at a glance means a brief summary here.


You can also check out the [Hooks API reference](/docs/hooks-reference.html) and the [Hooks FAQ](/docs/hooks-faq.html).
你也可以看看 [Hooks API reference](/docs/hooks-reference.html) [Hooks 常見問題](/docs/hooks-faq.html)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
你也可以看看 [Hooks API reference](/docs/hooks-reference.html)[Hooks 常見問題](/docs/hooks-faq.html)
你也可以看看 [Hook API reference](/docs/hooks-reference.html)[Hook 常見問題](/docs/hooks-faq.html)


Finally, don't miss the [introduction page](/docs/hooks-intro.html) which explains *why* we're adding Hooks and how we'll start using them side by side with classes -- without rewriting our apps.
最後,不要漏了[隆重介紹頁面](/docs/hooks-intro.html),這裡解釋了 *為什麼* 我們加入了 Hooks 與我們如何和 class 一起使用——不用重寫我們的應用程式。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
最後,不要漏了[隆重介紹頁面](/docs/hooks-intro.html),這裡解釋了 *為什麼* 我們加入了 Hooks 與我們如何和 class 一起使用——不用重寫我們的應用程式。
最後,不要漏了[隆重介紹頁面](/docs/hooks-intro.html),這裡解釋了 *為什麼* 我們加入了 Hook 與我們如何和 class 一起使用——不用重寫我們的應用程式。

@chloewlin chloewlin added In Review Currently under review and removed Review Needed labels Mar 13, 2019
@BruceWeng
Copy link
Contributor Author

Hi @chloewlin ,
Thanks for reviewing! I have made the following changes:

  1. Change all Hooks to Hook (Singular)
  2. Properly translate "at a glance" to 「概論」
  3. Properly spacing between English and Chinese
  4. Use prop in singular and keep "tree" in English

Let me know if you find a further suggestion in the article. Thanks!

const [age, setAge] = useState(42);
const [fruit, setFruit] = useState('banana');
const [todos, setTodos] = useState([{ text: 'Learn Hooks' }]);
// ...
}
```

The [array destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring) syntax lets us give different names to the state variables we declared by calling `useState`. These names aren't a part of the `useState` API. Instead, React assumes that if you call `useState` many times, you do it in the same order during every render. We'll come back to why this works and when this is useful later.
[Array destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring) 語法讓我們可以給用呼叫 `useState` 宣告的 state 變數不同的名字,這些名字不是 `useState` API 的一部份。相反地,React 假設如果你呼叫 `usetState` 多次,你在每次 render 用同樣的順序。我們之後將會回來討論為什麼可以這樣做與什麼時候他很有用。
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
[Array destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring) 語法讓我們可以給用呼叫 `useState` 宣告的 state 變數不同的名字,這些名字不是 `useState` API 的一部份。相反地,React 假設如果你呼叫 `usetState` 多次,你在每次 render 用同樣的順序。我們之後將會回來討論為什麼可以這樣做與什麼時候他很有用。
[Array destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Array_destructuring) 語法讓我們可以給用呼叫 `useState` 宣告的 state 變數不同的名字,這些名字不是 `useState` API 的一部份。相反地,React 假設如果你呼叫 `useState` 多次,你在每次 render 用同樣的順序。我們之後將會回來討論為什麼可以這樣做與什麼時候他很有用。

@@ -229,19 +229,19 @@ function FriendListItem(props) {
}
```

The state of these components is completely independent. Hooks are a way to reuse *stateful logic*, not state itself. In fact, each *call* to a Hook has a completely isolated state -- so you can even use the same custom Hook twice in one component.
這兩個 component 的 state 是完全獨立的。Hook 是一種重複使用 *statefule 邏輯* 的方式,不是 state 本身。實際上,每一次呼叫一個 Hook 都有一個完全獨立且隔離的 state —— 所以你甚至可以在一個 component 使用同一個客製化 Hook 兩次。
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
這兩個 component 的 state 是完全獨立的。Hook 是一種重複使用 *statefule 邏輯* 的方式,不是 state 本身。實際上,每一次呼叫一個 Hook 都有一個完全獨立且隔離的 state —— 所以你甚至可以在一個 component 使用同一個客製化 Hook 兩次。
這兩個 component 的 state 是完全獨立的。Hook 是一種重複使用 *stateful 邏輯* 的方式,不是 state 本身。實際上,每一次呼叫一個 Hook 都有一個完全獨立且隔離的 state —— 所以你甚至可以在一個 component 使用同一個客製化 Hook 兩次。


Custom Hooks are more of a convention than a feature. If a function's name starts with "`use`" and it calls other Hooks, we say it is a custom Hook. The `useSomething` naming convention is how our linter plugin is able to find bugs in the code using Hooks.
客製化 Hook 比較像慣例而不是功能,如果一個 function 的名字是「`use`」開頭且他呼叫其他 Hook,我們將他稱之為客製化 Hook。使用 Hook 時,`useSometing`的命名慣例是我們的 linter plugin 如何能夠在程式碼中找到 bug 的原因。
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
客製化 Hook 比較像慣例而不是功能,如果一個 function 的名字是「`use`」開頭且他呼叫其他 Hook,我們將他稱之為客製化 Hook。使用 Hook 時,`useSometing`的命名慣例是我們的 linter plugin 如何能夠在程式碼中找到 bug 的原因。
客製化 Hook 比較像慣例而不是功能,如果一個 function 的名字是「`use`」開頭且他呼叫其他 Hook,我們將他稱之為客製化 Hook。使用 Hook 時,`useSomething`的命名慣例是我們的 linter plugin 如何能夠在程式碼中找到 bug 的原因。

Copy link
Contributor

@vrabe vrabe left a comment

Choose a reason for hiding this comment

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

Just some typos.

@BruceWeng
Copy link
Contributor Author

Hi @vrabe ,
Thank you for taking time reviewing the article! I have fixed the typos in the new commit.

@BruceWeng
Copy link
Contributor Author

Hi @chloewlin,
Can we merge it if there is no concern about the translation? Thanks.

@bugtender
Copy link
Member

Hey, @BruceWeng thanks for your contribution.👍
Could you rebase this pull request to the head? I'll merge it after that. 👌

@BruceWeng
Copy link
Contributor Author

BruceWeng commented Mar 23, 2019

Thanks @bugtender . I have rebased the PR to HEAD.

@bugtender bugtender merged commit 9bac071 into reactjs:master Mar 23, 2019
@neighborhood999 neighborhood999 added Completed and removed In Review Currently under review labels Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants